I'm using Rails helpers to generate buttons and I'm trying to style the buttons with Twitter bootstrap styles for buttons. I've added classes with the :html
option. The page isn't breaking but the styles aren't showing up.
<%= button_to('Sign Up', new_user_registration_path, :html => {:class => 'btn.btn-large.btn-primary'}) %>
<%= button_to "Sign Up", user_omniauth_authorize_path(:facebook), :html => {:class => 'btn.btn-large.btn-primary'} %>
This is page source for the facebook button
<form action="/users/sign_up" class="button_to" method="post"><div><input html="{:class=>"btn.btn-large.btn-primary"}" type="submit" value="Sign Up" /><input name="authenticity_token" type="hidden" value="QIvZqd9BRV8TMspMvckAUjhC68nm3NTyQCxVRHFA4PE=" /></div></form>
<form action="/users/auth/facebook" class="button_to" method="post"><div><input html="{:class=>"btn.btn-large.btn-primary"}" type="submit" value="Sign Up" /><input name="authenticity_token" type="hidden" value="QIvZqd9BRV8TMspMvckAUjhC68nm3NTyQCxVRHFA4PE=" /></div></form>
any idea what I'm doing wrong?
You just need :class => "foo"
to set the class of the button, instead of :html => { :class => "foo" }
. So it should look like this:
<%= button_to('Sign Up', new_user_registration_path, :class => 'btn btn-large btn-primary') %>
This will generate your large primary button.
The above answer got close to a fix for me but needed to change the button_to
to a link_to
. Also got rid of the rocket... =>
<%= button_to('Sign Up', new_user_registration_path, class: 'btn btn-large btn-primary') %>
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