Rails: Why images are not showing in my rails basic app

后端 未结 4 1566
遥遥无期
遥遥无期 2020-12-30 03:44

my index.html.erb code -

Listing products

<% @products.each do |product| %>
4条回答
  •  再見小時候
    2020-12-30 04:09

    As Srikanth already said, the assets path should be referenced. As an example you could put <%= image_tag 'rails.png' %> within your code and check firebug (or inspect element within chrome) to check the result.

    I'm not quite sure why your code is not working, since I can see you followed Agile Web Development with Rails. I got the depot application running without problems. In your table I see you 'Product1', 'Product2' and 'Product3', is this what you actually filled in within the image_url text_field? What happens if you change 'Product1' to 'product1.jpg'?

    On a side note, if you want to use Paperclip, your call should look like this:

    <%= image_tag(product.image.url, class: 'list_image') %>
    

提交回复
热议问题