Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed font-awesome icon in Rails button_to

I would like to have a button as follow:

[ Sign in with FB]

where FB is a font-awesome icon. I tried the following, but couldn't figure out how to embed the icon to the button:

= button_to "Login with", user_omniauth_authorize_path(:facebook)

Here is how font-awesome is normally invoked (in haml):

%i.icon-facebook-sign

How do I achieve the effect I want?

Thank you.

like image 888
AdamNYC Avatar asked Mar 12 '13 04:03

AdamNYC


3 Answers

You can pass a block to button_to like so:

= button_to user_omniauth_authorize_path(:facebook) do
    Login with
    %i.icon-facebook-sign

(Though I'm not sure why you wouldn't just use the Facebook icon itself as the button.)

like image 141
markquezada Avatar answered Sep 27 '22 00:09

markquezada


Add class option for button_to helper

= button_to "Login with", user_omniauth_authorize_path(:facebook), :class => 'icon-facebook-sign'
like image 42
ranendra Avatar answered Sep 26 '22 00:09

ranendra


try this code, it runs for me

<%= button_to line_items_path(product_id: produit.id),class:"btn btn-outline-primary" do %> <i class="fas fa-shopping-basket"></i> <% end %>

just change the icon

like image 26
S-Toky Avatar answered Sep 24 '22 00:09

S-Toky