From 0cd8307c36a839d393b2c829c3bf8f135383f05c Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Mon, 2 Jan 2012 11:37:57 -0800 Subject: [PATCH] Update validates_formatting_of dependency to version 0.4.0 Add validation for phone numbers. --- Gemfile.lock | 4 ++-- app/models/user.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 60f9d8a..7146645 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/sferik/rails_admin.git - revision: 086cfed1481bd9551262cbd4814a7fc260985cad + revision: 4e3014605b734f28942db836a2fc78692af05b10 specs: rails_admin (0.0.1) bbenezech-nested_form (~> 0.0) @@ -164,7 +164,7 @@ GEM uglifier (1.2.1) execjs (>= 0.3.0) multi_json (>= 1.0.2) - validates_formatting_of (0.3.7) + validates_formatting_of (0.4.0) rails (~> 3.0) warden (1.1.0) rack (>= 1.0) diff --git a/app/models/user.rb b/app/models/user.rb index 50673e6..d0b5a46 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,6 +5,8 @@ class User < ActiveRecord::Base :password, :password_confirmation, :remember_me, :sms_number, :state, :voice_number, :zip validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i + validates_formatting_of :sms_number, :using => :us_phone, :allow_blank => true + validates_formatting_of :voice_number, :using => :us_phone, :allow_blank => true validates_formatting_of :zip, :using => :us_zip, :allow_blank => true validates_presence_of :name has_many :reminders_to, :class_name => "Reminder", :foreign_key => "to_user_id"