Friday, November 8, 2013

Two ways to have in-line HTML for link_to

Sometimes we need to have multiple or complex HTML or ERB code in the link_to comment, we can do it as:
    <%= link_to post_path(@post) do %>
      <i class="icon-ok icon-white"></i> Go to the post@
    <% end %>
or
    <%= link_to '<i class="icon-ok icon-white"></i>"Go to the post@".html_safe, post_path(@post) %>
Just make a note for it!

No comments:

Post a Comment