Adding bootstrap button class to button_to in rails 4
button, haml, ruby-on-rails-4, twitter-bootstrap
Solution
You need to make sure the second and third parameters to `button_to` are separate. Currently the `action` and `class` keys are being passed as a single hash, but they should be two arguments, one for `options` and one for `html_options`.
Try (note the extra `{...}` around `action: "new"` making it a separate hash):
= button_to("Click Me", { action: "new" }, class: "btn btn-primary")
Problem
I have a button_to call in my Rails 4 haml file that looks like this ``` = button_to("Click Me", action: "click", class: "btn btn-primary") ``` However, the `class: "btn btn-primary"` code snippet isn't working properly, and my button isn't changing. I've also tried the old Ruby syntax of `:class => "btn btn-primary"`, but that doesn't seem to do the trick. Any help would be greatly appreciated.