I’m fairly new to Ruby on Rails.
I’ve made a blog, and loaded a few entries include title, content and image (which is a string detailing the path of the image).
I’ve had a search around and can’t find a solution – I was just wondering whether there is a way that I can reference the data within the image field in an image_tag, so that the image field links to the relevent image?
Thanks.
Assuming You can use the following:
This supposes a few things:
blogentry(change accordingly)imagefield contains the relative path from the public/images (or assets/images) folderand if the path is always the same, you can do the following
in this example, the path to your images would be
app/public/images/path/to/your/image/(or app/assets/images/…).This also assumes your field contains the name and the extension.