From 11b4d4103e1c24cb773216b9116d260734395f3c Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Sun, 25 Nov 2007 22:37:08 -0800 Subject: [PATCH] Update Rails + Add Phone Number and Email Validation Signed-off-by: Ira W. Snyder --- app/models/customer.rb | 2 ++ config/environment.rb | 2 +- db/development.sqlite3 | Bin 25600 -> 25600 bytes public/stylesheets/videostore.css | 13 ------------- 4 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 public/stylesheets/videostore.css diff --git a/app/models/customer.rb b/app/models/customer.rb index 5509439..acd6869 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -62,6 +62,8 @@ class Customer < ActiveRecord::Base def validate errors.add(:debt, "should be non-negative") if debt.nil? || debt < 0.00 + errors.add(:email, "is invalid") unless email =~ /.+@.+\..+/ + errors.add(:phone, "has invalid format, use XXX-XXX-XXXX") unless phone =~ /^\d{3}-\d{3}-\d{4}$/ end end diff --git a/config/environment.rb b/config/environment.rb index 4233311..ab75a0f 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -5,7 +5,7 @@ # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '1.2.5' unless defined? RAILS_GEM_VERSION +RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 0a336e5d64035d3727cd4a1bfec1e45439a461ac..86d8540519e4d00f888fae96ff16a2ee6e79a527 100644 GIT binary patch delta 201 zcmZoT!Pszuae_2s%to0P>_Y5JqHIj*%tFkWOoy3oGp}S4-Prh_F))Cgok7)CSCuh1 zF)t;xNWnEHCp9NHKQ~n&xTGjGwS<=o%yG^vsf044JOhfsY8_I6YK!!e^K%W2jCD;+ z&2-HzEDbiNam{087GTtx%q}3$#Hh8gk%`g5On{3)+>)PBlaYZTEHfoFKO`enA*3j= pEHx)HFI^!xF(;h~|=|IFR#GJ`=nE5vI%8iY|Oq