我在Rails中有一个form_tag,如下所示:
<%= form_tag(listings_path, method: :get) do %>
What
<%= text_field_tag :title, "",class: 'form-control' %>
Category
<%= select_tag(:category_id, options_from_collection_for_select(Category.all, :id, :name), { :prompt => 'All Categories' }) %>
Area
<%= select_tag(:area, options_for_select(['All', 'Ireland', 'UK']), class: "form-control") %>
<%= submit_tag 'Search', name: nil, class: "btn btn-primary" %>
<% end %>
我应该在哪里添加CSS选项>>类:“ form-control” <
最佳答案
我将其设置为与您在我的应用程序中稍有不同,但这是可行的。
...
<% options = options_from_collection_for_select(Category.all, :id, :name) %>
<%= f.select :category_id, options, class: "form-control", :include_blank => 'All Categories' %>
...