carmen-rails icon indicating copy to clipboard operation
carmen-rails copied to clipboard

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

Open ayraju opened this issue 12 years ago • 6 comments

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

Any help?

ayraju avatar Feb 07 '13 03:02 ayraju

c = Carmen::Country.coded('AU')
 => <#Carmen::Country name="Australia"> 
c.name
 => "Australia" 

jason-rutherford avatar Mar 11 '13 21:03 jason-rutherford

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

yes I found this but forgot to update it .

Anyway thank you.

ayraju avatar Mar 12 '13 04:03 ayraju

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?

lawrobi avatar Dec 09 '13 16:12 lawrobi

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.

frandroid avatar Dec 09 '13 21:12 frandroid

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

lawrobi avatar Dec 09 '13 21:12 lawrobi

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

frandroid avatar Dec 09 '13 22:12 frandroid