ruby-on-rails-4twitter-bootstrap-3button-to

button_to breaks styling from bootstrap 3 button tag


I had some tags like this:

<div class="container">
<div class="row">
    <div class="col-md-8">
       <button type="button" class="btn btn-default btn-lg">
  <span class="glyphicon glyphicon-user" aria-hidden="true" href="/groups"></span> Group/Provider
       </button>
       <button type="button" class="btn btn-default btn-lg">
  <span class="glyphicon glyphicon-usd" aria-hidden="true"></span> Billing
       </button>

<!-- etc -->

This worked great, the buttons were lining side by side. Then when I went to this: Button_to the buttons no longer arrange side by side:

 <%= button_to(groups_url, :class => 'btn btn-default btn-lg') do %> 
    <span class="glyphicon glyphicon-user" aria-hidden="true"></span>Group
 <% end %>

 <%= button_to(providers_url, :class => 'btn btn-default btn-lg') do %> 
    <span class="glyphicon glyphicon-user" aria-hidden="true"></span>Provider
<% end %>       

Even though the same class was being used, any ideas? Guessing button_to has some specific styling II would like to use the button_to url helper but I want my form to look nice...ideas suggestions?


Solution

  • Rails button_to actually creates a form and an input (see the docs for example markup). Instead, I think you just want a link styled like a button, so use link_to and add the Bootstrap button classes:

    link_to('Button Text', groups_url, :class => 'btn btn-default btn-large)