PhonyNumber
This Gem adds useful methods to your Rails app to validate, display and save phone numbers. It uses the super awesome Phony gem (https://github.com/floere/phony).
Installation
Add this line to your application's Gemfile:
gem 'phony_number'
And then execute:
$ bundle
Or install it yourself as:
$ gem install phony_number
Usage
In your model add:
class SomeModel < ActiveRecord::Base
phony_normalize_numbers :phone_number, :default_country_code => 'US'
end
Use the Phony.plausible method to validate an attribute:
validate :phone_number, :phony_number => true
In your views use:
<%= "some number string variable".phony_formatted(:format => :international, :spaces => '-') %>
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request