carrierwave doesn't render, path exists but im

2019-04-13 07:44发布

问题:

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.