3

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.

4

1 回答 1

7

您需要确保第二个和第三个参数button_to是分开的。目前actionandclass键作为单个散列传递,但它们应该是两个参数,一个 foroptions和一个 for html_options

尝试(注意将其设置为单独的哈希的额外内容){...}action: "new"

= button_to("Click Me", { action: "new" }, class: "btn btn-primary")
于 2013-07-30T19:40:53.987 回答