Skip to content

Instantly share code, notes, and snippets.

@jfriedlaender
Created June 10, 2011 10:29
Show Gist options
  • Save jfriedlaender/1018597 to your computer and use it in GitHub Desktop.
Save jfriedlaender/1018597 to your computer and use it in GitHub Desktop.
Internationalize phone numbers
def self.internationalize_phone_number(number, country)
c = Country[Country.find_by_name(country)[0]]
if c
number = Phony.normalize(number)
number = "#{c.country_code}#{number}" unless number.starts_with?(c.country_code)
end
number = Phony.normalize(number)
number
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment