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.