0
我有以下形式:如何在options_from_collection_for_select中预先选择?
<%= form_tag users_path, method: :get, id: 'uco' do %>
<%= select_tag "country", options_from_collection_for_select(ISO3166::Country.countries.sort_by(&:name), 'un_locode', 'name'), :include_blank => true %>
<%= submit_tag "Search" %>
<% end %>
当我提交表单,我结束了:
www.example.com/users?country=US
我会然后像预先选择的形式params[:country]
。
但是我不知道如何将params[:country]
添加到select_tag中。我尝试过失败:基于关this example from the apidock.