在Rails 4中,我试图将CSS类添加到Active Admin Dashboard上的循环内的按钮上
button_to "Block", action: :block_cars, controller: :companies, id: company
但是,这似乎不起作用:
button_to "Block", :class => 'dangerbtn', action: :block_cars, controller: :companies, id: company
任何帮助将不胜感激,谢谢。
最佳答案
class
是HTML选项,但是您可以在选项哈希中使用它。尝试像这样:
button_to "Block", {action: :block_cars, controller: :companies, id: company}, {:class => 'dangerbtn'}
button_to
具有以下格式:button_to(name = nil, options = nil, html_options = nil, &block)
有关更多详细信息,请参见the API。