From deffc9d048d652b2da9b24a60fb3244cbcd9de55 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 25 May 2011 16:19:06 +0530 Subject: changes validates_uniqueness_of to newer syntax --- .../guides/source/active_record_validations_callbacks.textile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index ad80bfb63e..d2616e0b8e 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -381,7 +381,7 @@ This helper validates that the attribute's value is unique right before the obje class Account < ActiveRecord::Base - validates_uniqueness_of :email + validates :email, :uniqueness => true end @@ -391,7 +391,7 @@ There is a +:scope+ option that you can use to specify other attributes that are class Holiday < ActiveRecord::Base - validates_uniqueness_of :name, :scope => :year, + validates :name, :uniqueness => true, :scope => :year, :message => "should happen once per year" end @@ -400,7 +400,7 @@ There is also a +:case_sensitive+ option that you can use to define whether the class Person < ActiveRecord::Base - validates_uniqueness_of :name, :case_sensitive => false + validates :name, :uniqueness => true, :case_sensitive => false end @@ -503,7 +503,7 @@ The +:on+ option lets you specify when the validation should happen. The default class Person < ActiveRecord::Base # it will be possible to update email with a duplicated value - validates_uniqueness_of :email, :on => :create + validates :email, :uniqueness => true, :on => :create # it will be possible to create the record with a non-numerical age validates_numericality_of :age, :on => :update -- cgit v1.2.3