下拉铁路4国家列表的最佳方式

我有一个表单,用户输入一些信息,我想添加到这个表单一个国家,我正在徘徊是什么是最好的方式来做这个(种子数据,Csv,…)我不想使用gem

由于这本质上是静态数据,我甚至不会将其存储到数据库中。 我会创建一个PORO,它有一个返回二维数组的类方法(具有国家缩写的国家/地区)。 这只是一个采购数据的问题。

这是您可以使用的列表。

https://github.com/karmi/localized_country_select/blob/master/locale/en.rb

我使用country_select gem。 它使用起来非常简单。 只需提供模型和属性作为参数:

country_select("user", "country") 

以下是我的一个表单中的示例:

 <%= f.fields_for (:address) do |b2| %> <%= b2.input :street %> <%= b2.input :city, :label => "City/Suburb" %> <%= b2.input :state %> <%= b2.input :post_code %> 
<%= b2.country_select :country, ["Australia", "New Zealand"] %>
<% end %>