carrierwave doesn't render, path exists but image doesn't show up

混江龙づ霸主 提交于 2019-12-06 10:06:25

问题


ive been trying to render a picture from carrierwave. i believe it is uploaded correctly because when i view the page source, i see

<img alt="Photo_44" src="/uploads/user/image/59/Photo_44.jpg" />

however by clicking on that src url, i get

No route matches [GET] "/uploads/user/image/59/Photo_44.jpg"

im using the default settings for carrierwave. the image does correctly get uploaded to my image column in my users table and locally, the path

sasha/Desktop/rails_projects/myproject/public/uploads/user/image/59/Photo_44.jpg

exists as well. however it won't display correctly. ive been following the railscasts

http://railscasts.com/episodes/253-carrierwave-file-uploads?autoplay=true

and reading

https://github.com/jnicklas/carrierwave

but i cant seem to figure out what is wrong. where i upload the image is here

<%= 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 %>

and im trying to render it by...

<%= image_tag @user.image_url.to_s %>

what am i doing wrong? help would be appreciated = ) thank you


回答1:


Try set config.serve_static_assets = true if you haven't yet, should help.



来源:https://stackoverflow.com/questions/10612914/carrierwave-doesnt-render-path-exists-but-image-doesnt-show-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!