【发布时间】:2012-05-01 21:19:51
【问题描述】:
我正在使用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 中,但我不知道该怎么做。请指教。谢谢
【问题讨论】:
标签: ruby-on-rails-3 inline-editing best-in-place