Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added more info.

  • Loading branch information...
commit e71c85c12281f706bd011c7dea64b57ff1f8055f 1 parent c71e8e2
@joost authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 README.md
View
18 README.md
@@ -21,6 +21,8 @@ Or install it yourself as:
## Usage
+### ActiveRecord Extensions
+
In your model add:
class SomeModel < ActiveRecord::Base
@@ -39,14 +41,24 @@ The `:default_country_code` options is used to specify a country_code when norma
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'`.
+### Validations
+
Use the Phony.plausible method to validate an attribute:
validates :phone_number, :phony_plausible => true
+### Views
+
In your views use:
<%= "some number string variable".phony_formatted(:format => :international, :spaces => '-') %>
+### Find by normalized number
+
+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.1.6
@@ -77,6 +89,12 @@ In your views use:
0.0.6
* Fixed problem with '070-4157134' being parsed as US number
+## TODO
+
+* Make this work: Home.find_by_normalized_phone_number(Home.normalize_number(params[:phone_number]))
+ So we use Home.normalize_number instead of PhonyRails.normalize_number. This way we can use the same default_country_code.
+* Make country_code method configurable.
+
## Contributing
1. Fork it
Please sign in to comment.
Something went wrong with that request. Please try again.