carmen-ruby / carmen-rails

NOT ACTIVELY MAINTAINED Rails adapter for Carmen (provides country_select and subregion_select)
MIT License
215 stars 159 forks source link

Complete country name from the code like 'Australia' from 'AU' #18

Open ayraju opened 11 years ago

ayraju commented 11 years ago

How can we get complete country name from the code like 'Australia' from 'AU'?

Any help?

jason-rutherford commented 11 years ago
c = Carmen::Country.coded('AU')
 => <#Carmen::Country name="Australia"> 
c.name
 => "Australia" 
ayraju commented 11 years ago

@c= 'US' @country = Carmen::Country.coded(@c)

yes I found this but forgot to update it .

Anyway thank you.

lawrobi commented 10 years ago

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?

frandroid commented 10 years ago

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.

lawrobi commented 10 years ago

yes when I print @country there is nothing (blank)... even though country_zone = US for that user.

frandroid commented 10 years ago

My point is that what's returned is not a string, but a Country object. Maybe you could invoke the object's .name method?