我正在使用best_in_place gem 在线编辑记录,并使用country_select来呈现可供选择的国家列表。当使用 best_in_place 编辑选择字段时,我这样做:
<%= best_in_place(@home, :country_name, :type => :select, :collection => [[1, "Spain"], [2, "Italy"]]) %>
现在我想获取 country_select 拥有的所有国家/地区的列表,并将其传递到集合参数中。country_select gem 提供了一个简单的助手来呈现选择字段:
<%= country_select("home", "country_name") %>
我想替换 best_in_place 助手中的 :collection 参数以包含由 country_select 提供的国家/地区列表。我知道 best_in_place 期望 [[key, value], [key, value],...] 输入到 :collection 中,但我不知道该怎么做。请指教。谢谢