Reputation: 195
This same question has already been posted on this link but hasn't been solved and I don't really understand the readme in country_select github page.
I hope you understand :)
Upvotes: 2
Views: 6350
Reputation: 1668
Its given in the docs
class User < ActiveRecord::Base
# Assuming country_select is used with User attribute `country_code`
# This will attempt to translate the country name and use the default
# (usually English) name if no translation is available
def country_name
country = ISO3166::Country[country_code]
country.translations[I18n.locale.to_s] || country.name
end
end
Here is the link https://github.com/stefanpenner/country_select#getting-the-country-name-from-the-countries-gem
UPDATE
In your SurfSchool
model
def country_name
c = ISO3166::Country[self.country]
return c.translations[I18n.locale.to_s] || c.name
end
So anywhere in your controller or view
@surfschool.country_name // this will give country name
Upvotes: 8