我无法在此collection_select中添加一个类:
<%= f.collection_select :category_id, Category.all, :id, :name, {:prompt => 'Choose a category'}, {:required => true} %>
我试过这个:
<%= f.collection_select :category_id, Category.all, :id, :name, {:prompt => 'Choose a category'}, {:required => true}, {:class => "form_inputs"} %>
以及:
<%= f.collection_select :category_id, Category.all, :id, :name, {prompt: "Choose a category"}, {required: true}, {class: "form_inputs"} %>
但似乎都不起作用。是什么给了什么?
答案 0 :(得分:0)
Try like this
<%= f.collection_select :category_id, Category.all, :id, :name, {:prompt => 'Choose a category'}, :class => "form_inputs" %>
答案 1 :(得分:0)
试试这个...测试。
<%= f.collection_select 'category_id', Category.all, 'id', 'name', {prompt: "Choose a category"}, class: "form_inputs", required:true %>