Ruby on rails 如何从country_select gem中将国家列表提取到数组中

Ruby on rails 如何从country_select gem中将国家列表提取到数组中,ruby-on-rails,x-editable,Ruby On Rails,X Editable,我试图提取所有国家名称的列表,并将它们从列表中放入一个数组中。在表单中添加select字段时,如何利用这个gem是非常清楚的: <%= form_for User.new, url: root_url do |f| %> <%= f.country_select :country_code %> <% end %> 及 有谁能帮助我们实现这一点吗?国家/地区\u选择gem将gem作为依赖项。gem为与各国合作提供了查找工具和其他有用的方法 ISO31

我试图提取所有国家名称的列表,并将它们从列表中放入一个数组中。在表单中添加select字段时,如何利用这个gem是非常清楚的:

<%= form_for User.new, url: root_url do |f| %>
  <%= f.country_select :country_code %>
<% end %>



有谁能帮助我们实现这一点吗?

国家/地区\u选择gem将gem作为依赖项。gem为与各国合作提供了查找工具和其他有用的方法


ISO3166::Country。所有翻译的
可能就是您正在寻找的方法。

尝试检查
@countries
并检查返回的内容。同时检查浏览器中的可编辑字段,并将为该字段生成的HTML粘贴到控制台中。非常感谢Igor。正是我想要的。
<%= editable @waiter, :country, type: :select, title: 'Your country', source: ["Country_1", "Country_2", "Country_n"] %>
@countries = ActionView::Helpers::FormOptionsHelper::COUNTRIES.zip(ActionView::Helpers::FormOptionsHelper::COUNTRIES)
<%= @countries = ActionView::Helpers::FormOptionsHelper::COUNTRIES %>