Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails link_to with fa_icon and html properties

Is there a way to use

Rails link_to function with fa_icon (FontAwesome gem)

like below?

=link_to fa_icon("off"), destroy_user_session_path, :method=>'delete', {"data-toggle" => "tooltip", "data-original-title" => "Logout", "data-placement" => "bottom", :class => "btn btn-metis1 btn-sm"}
like image 497
Passionate Engineer Avatar asked Oct 29 '13 06:10

Passionate Engineer


2 Answers

link_to (fa_icon "off"), other_options_go_here

That works for me.

like image 126
topher Avatar answered Oct 17 '22 07:10

topher


This usually works fine.

<%= link_to new_message_path, :class=> "you_class" do %>
    <i class="fa fa-envelope-o" aria-hidden="true" target="_blank"></i>
<% end %>

P.S any other html properties can be placed like the id, class etc. And noticed, It's better to place everything in a single line, like:

<%= link_to new_message_path, :class=> "you_class" do %><i class="fa fa-envelope-o" aria-hidden="true" target="_blank"></i><% end %>

else it outputs some character to the right, just after the icon.

like image 41
MulleOne Avatar answered Oct 17 '22 06:10

MulleOne