我一直在尝试从载波渲染图片。我相信它已正确上传,因为当我查看页面源时,我看到了
<img alt="Photo_44" src="/uploads/user/image/59/Photo_44.jpg" />
但是,通过单击该 src url,我得到
No route matches [GET] "/uploads/user/image/59/Photo_44.jpg"
我使用载波的默认设置。图像确实正确上传到我的用户表中的图像列和本地路径
sasha/Desktop/rails_projects/myproject/public/uploads/user/image/59/Photo_44.jpg
也存在。但是它不会正确显示。我一直在关注railscasts
http://railscasts.com/episodes/253-carrierwave-file-uploads?autoplay=true
和阅读
https://github.com/jnicklas/carrierwave
但我似乎无法弄清楚出了什么问题。我上传图片的地方在这里
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name),
:html => { :method => :put, :multipart => true }) do |f| %>
<%= devise_error_messages! %>
<%= render '/shared/fields', object: f.object, f: f %>
<%= f.submit "Save changes", :class => "btn btn-large btn-primary", :style =>"display:block;" %>
<div class="edit_avatar" >
<%= f.file_field :image %>
</div>
<% end %>
我试图通过...渲染它
<%= image_tag @user.image_url.to_s %>
我究竟做错了什么?帮助将不胜感激=)谢谢