Reputation: 1993
How do I embed additional HTML inside of a link_to call?
Here is my desired result:
<a href="/exercies/show/1"><i class="icon-show"></i>Show</a>
Here is my link_to call
<%= link_to "Show", exercise_path(exercise) %>
Upvotes: 2
Views: 1372
Reputation: 941
It is cleaner if you wrap it in a do block
<%= link_to exercise_path(exercise) do %>
<i class="icon-search"></i> Show
<% end %>
Upvotes: 1
Reputation: 1993
<%= link_to '<i class="icon-search"></i> Show'.html_safe, exercise_path(exercise), :class => 'btn btn-small' %>
.html_safe is required so that it is not escaped.
Upvotes: 5