Rails button_to – 将css类应用于按钮
这很愚蠢,但我无法弄清楚如何设置由Rails button_to
创建的输入元素的样式 – 是的,我已经一遍又一遍地阅读文档并尝试了样本。
这是我的ERB代码:
这会产生以下HTML:
而我想要的只是input
class = "btn btn-small"
。
救命? 谢谢!
button_to
方法的签名是
button_to(name = nil, options = nil, html_options = nil, &block)
因此,使用{}
来区分options
和html_options
<%= button_to "Claim", {action: "claim", idea_id: idea.id, remote: true}, {class: 'btn btn-small'} %>
<%= button_to "Claim", {action: "claim", idea_id: idea.id, remote: true}, {form_class: 'form', class: 'btn btn-small'} %>
form_class:表单的类
class:表单中按钮的类