Getting a HAML button_to work with twitter bootstrap

haml, ruby-on-rails, twitter-bootstrap

Solution

If you're trying to get a button tag in HAML you can use the `%button` tag to generate it.

In order to change the class you would be able to do `%button.class`

ex.

%button.alert
  Test

Would generate

<button class="alert">Test</button>

EDIT:

Just a bit extra, while I'm not experienced with using Bootstrap (I used Foundation), if you're interested in using `button_to` you're allowed to declare the class, though it won't generate the tag you're looking for so this part is not related to your question.

= button_to 'Example, {:controller => 'your_controller', :action => 'your_action'}, {:class => 'your button class', :method => 'post'}

However this will generate a

<input class="small button" type="submit" value="Example">

Problem

I am trying to apply some basic formatting to a Ruby on Rails app using Twitter Bootstrap. I would like to create a button group with three buttons but am having trouble with my haml file. After looking through all the Twitter Bootstrap Documentation, I think the problem is that the bootstrap style-sheet is expecting `<button>` elements (with the proper classes) to place in the button group. I am currently using the `button_to` helper in my haml file which does not appear to produce the `<button>` tag. But, I am not experienced enough in haml to know a way around this. Is there a way to make the `button_to` element generate a `<button>` tag, or should I be attacking this problem in a different way?

Original source