如何将country_select用作select_tag?
在form_for中使用country_select非常简单。
但现在,我想用它作为按国家过滤的方式。
你能指出我正确的方向吗?
如果你正在使用stefanpenner / country_select country_select
那么
<%= select_tag "country", options_from_collection_for_select(ISO3166::Country.countries.sort_by(&:name), 'un_locode', 'name') %>
或者如果你正在使用jim / carmen-rails country_select
那么
<%= select_tag "country", options_from_collection_for_select(Carmen::Country.all.sort_by(&:name), 'code', 'name') %>
希望这会有所帮助