README.md in phony_rails-0.3.2 vs README.md in phony_rails-0.4.0
- old
+ new
@@ -19,13 +19,13 @@
$ gem install phony_rails
## Usage
-### Normalization / ActiveRecord Extension
+### Normalization / Model Usage
-In your model add:
+For **ActiveRecord**, in your model add:
class SomeModel < ActiveRecord::Base
# Normalizes the attribute itself before validation
phony_normalize :phone_number, :default_country_code => 'US'
@@ -35,10 +35,19 @@
# Creates method normalized_fax_number that returns the normalized version of fax_number
phony_normalized_method :fax_number
end
+For **Mongoid**, in keeping with Mongoid plug-in conventions you must include the `Mongoid::Phony` module:
+
+ class SomeModel
+ include Mongoid::Document
+ include Mongoid::Phony
+
+ # methods are same as ActiveRecord usage
+ end
+
The `:default_country_code` options is used to specify a country_code when normalizing.
PhonyRails will also check your model for a country_code method to use when normalizing the number. So `'070-12341234'` with `country_code` 'NL' will get normalized to `'317012341234'`.
You can also do-it-yourself and call:
@@ -98,9 +107,12 @@
Say you want to find a record by a phone number. Best is to normalize user input and compare to an attribute stored in the db.
Home.find_by_normalized_phone_number(PhonyRails.normalize_number(params[:phone_number]))
## Changelog
+
+0.4.0
+* Better Mongoid support by @johnnyshields
0.3.0
* Now ability to force change a country_code.
See: https://github.com/joost/phony_rails/pull/23#issuecomment-17480463
\ No newline at end of file