我正在使用Country gem https://github.com/hexorx/countries,需要帮助
list = Country.find_all_countries_by_region('Americas')
我有以下方法
def get_Americas_countries
@job_countries = Refinery::Jobs::Job.select("DISTINCT(country)").all
# ::ISO3166::Country.find_all_countries_by_region('Americas')
end
在我的应用程序控制器中,我获取所有国家/地区的列表,但我想只获得来自美洲地区的国家/地区。我无法弄明白我该怎么做。任何帮助将非常感激。
答案 0 :(得分:1)
def get_Americas_countries
list = Country.find_all_countries_by_region('Americas').map(&:alpha2)
@job_countries = Refinery::Jobs::Job.select("DISTINCT(country)").where(:country => list)
end
[编辑]
list现在是一个国家/地区代码数组