Today I needed to add a select box for the internationals phone country codes.
This is also known as E.164
I wasn’t able to find a library for that, except for: https://github.com/hexorx/countries that I used as a base and extended this way:
c = ISO3166::Country::Data.map{ |_,v| v["country_code"].to_i }
codes = c.uniq.sort.map{ |v| "+#{v}" }
Now you can use the array in an options_for_select helper
Design by Simon Fletcher. Powered by Tumblr.
© Copyright 2010