carmen-rails
carmen-rails copied to clipboard
Complete country name from the code like 'Australia' from 'AU'
How can we get complete country name from the code like 'Australia' from 'AU'?
Any help?
c = Carmen::Country.coded('AU')
=> <#Carmen::Country name="Australia">
c.name
=> "Australia"
@c= 'US' @country = Carmen::Country.coded(@c)
yes I found this but forgot to update it .
Anyway thank you.
If we write this way in the controller
@c = 'current_user.country_code' @country = Carmen::Country.coded(@c)
It doesn't work ...
Can you help?
You say it doesn't work, but you don't say how. What do you get when you do p @country in the console, or you print @country on your web page? Surely some form of object got passed to @country... :) Look at both jason's and raju's code to understand.
yes when I print @country there is nothing (blank)... even though country_zone = US for that user.
My point is that what's returned is not a string, but a Country object. Maybe you could invoke the object's .name method?