I want to output the following with Ruby on Rails link_to
and image_tag
methods:
<a href="#">Lorem Ipsum <img src="/images/menu-arrow-down.gif"></a>
What would be a good way in Rails?
You can use blocks as an alternative to the string interpolation with correct usage html_safe
. For example:
<%= link_to '#' do %> Lorem Ipsum <%= image_tag('/images/menu-arrow-down.gif') %> <% end %>
Or a shorter way is
<%= link_to image_tag('image/someimage.png') + "Some text", some_path %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With