I am working on a Rails 4 app. In this app I have a bunch of "items" in my database. Each item has an attribute "image", which is a string where I store some html which contains an html image tag that links to another site. For example, a typical item has an image:
<a href=\"http://anotherpage.com\" target=\"_blank\"><img src=\"http://anotherpage.com/path/to/image\" ></a>
I render this image by calling:
<%= raw item.image %>
But I have certain cases, where I would like to render an image that is stored on my server. In previous version of rails, I could just stick an image in public, and use an image tag like so:
<img src="image.jpg" />
But I can't figure out how to do this with the asset pipeline. I know that I can do something like so:
<%= image_tag "image.jpg" %>
Or:
<img src="<%= asset_path('image.jpg') %>" />
But how could I store this in my database so that all I have to do to render it is:
<%= raw item.image %>
Is there a way that ruby code stored in my database, and output in a view can be interpreted?