-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a convenient way to get a hash or array of countries and their corresponding codes? #46
Comments
Hi Brian, Thanks, and thanks for the issue. I am not sure what you exactly need. Is it the names of the countries, mapped to country codes, or "Switzerland (+41)", or just the country code itself in the select ("41")? Cheers, |
Yep best would be country names mapped to codes like |
At the moment, Phony does not save any country names, since the focus is only on the numbers themselves. I did consider it, but including the names would bring with it a whole host of issues (multi-language names etc.). Are there any country gems that have this mapping ready? (Maybe the "countries" gem?) If not, maybe we can work something out, perhaps a 3166 to country code mapping, to be required separately in Phony. |
The countries gem has a |
Hi Brian, Glad to hear it! I'll think about doing a built-in solution. Cheers, |
Hey, I figured it out with the
Since it's semi-expensive I cached it in a helper:
Then you can call:
|
Great! I wonder about the |
Thanks! You're right, prob a bit overkill :) |
I'm trying to build a select menu for the user to choose their country, and auto-populate the country code.
Couldn't see an easy way to get a hash or array of these values though to build the select. Any ideas? Thanks for the great gem btw.
The text was updated successfully, but these errors were encountered: