I have an image model with an attribute :description which is a text, formatted as html text (e.g. with a few
in the text), which I display in a view as follows:
simple_format(@image.description)
raw(@image.description) will do mainly the same I think. How can I add a link_to helper with a link into that text? I’m searching for something like the following text (which will be @image.description):
Text text text text.
Text text #{link_to “Text”, @image.link)
@image.link will be the link. How can I do this?
Use ERB:
Wrap it in a helper method:
And use it like:
Some example content you could use for your image description could be: