html class in rails collection_select



如何添加 html 类名以选择轨道中的框

我尝试了以下方法,但出现语法错误

<%= f.collection_select :product, @product, :id, :name, selected: @post.product.id, html_options={class: 'tst'} %>
<%= f.collection_select :product, @product, :id, :name, selected: @post.product.id,{class: 'tst'} %>

<%= f.collection_select :product, @product, :id, :name, selected: @post.product.id, html_options: {class: 'tst'} %>

尝试了上述三种方法,但我无法修复它如何在其中添加一个 html 类。

我已经用 :class => classname 做了类似的事情

最新更新