I seeded my Rails db with the following for Posts: title, description, body, and image. For image I used data in the assets. So for example in the seed file I have:
post_image: '/images/main.image.jpg'
I'm able to hit all the other data in the views doing the typical:
<%= post.title %>
How do I pull in the image? I've tried the following to no avail:
Did I seed incorrectly or am I just using the wrong helper to get the image?
Yeah I seeded incorrectly. Image_tag will hit images under the asset pipeline. Did a db:reset after I fixed the seed file to just be: post_image: 'main.image.jpg'. Correct code is:
<%= image_tag post.post_image %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.