I am using country gem https://github.com/hexorx/countries and trying to get the the country name from alpha2 country names. but it comes as [object object]. here is my code.
render :json => @countries.map { |c| [c.id, ::ISO3166::Country[c.country]] }
This returns aplha2 fine as expected, which is saved in country column:
render :json => @countries.map { |c| [c.id, c.country] }
You need to pass hash (data
) instead of Country
instance.
render :json => @countries.map { |c| [c.id, ::ISO3166::Country[c.country].data] }
If you want only country name, use name
:
render :json => @countries.map { |c| [c.id, ::ISO3166::Country[c.country].name] }