country_select在展示行动中显示完整的国家/地区名称 [英] country_select display full country name on show action
本文介绍了country_select在展示行动中显示完整的国家/地区名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用gem'country_select'在我的Rails应用中为表单选择一个国家,但是当我转到展示或索引操作时,我会看到存储的值。有没有方法将该值转换为国家的全名字符串?
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"
推荐答案
文档包括如何获取正是你想要的。
country = ISO3166::Country[country_code]
country.translations[I18n.locale.to_s] || country.name
这篇关于country_select在展示行动中显示完整的国家/地区名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文