country_select display full country name on show action

孤街醉人 提交于 2019-12-08 14:14:14

问题


I use the gem 'country_select' to choose a country for a form on my rails app however when I go to a show or index action I see the stored value. Is there a method to convert the value to a full name string of the country?

[AU] => "Australia"

回答1:


The documentation includes how to get exactly what you want.

country = ISO3166::Country[country_code]
country.translations[I18n.locale.to_s] || country.name


来源:https://stackoverflow.com/questions/32193447/country-select-display-full-country-name-on-show-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!