diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2011-05-25 16:19:06 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2011-05-25 22:17:36 +0530 |
commit | deffc9d048d652b2da9b24a60fb3244cbcd9de55 (patch) | |
tree | be3dd93fb472b2884ddc944341e4f6fe43651eca /railties | |
parent | 45989b816e6131ccd9dc5451c9e75baee6fb704b (diff) | |
download | rails-deffc9d048d652b2da9b24a60fb3244cbcd9de55.tar.gz rails-deffc9d048d652b2da9b24a60fb3244cbcd9de55.tar.bz2 rails-deffc9d048d652b2da9b24a60fb3244cbcd9de55.zip |
changes validates_uniqueness_of to newer syntax
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/active_record_validations_callbacks.textile | 8 |
1 files changed, 4 insertions, 4 deletions
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 <ruby> class Account < ActiveRecord::Base - validates_uniqueness_of :email + validates :email, :uniqueness => true end </ruby> @@ -391,7 +391,7 @@ There is a +:scope+ option that you can use to specify other attributes that are <ruby> class Holiday < ActiveRecord::Base - validates_uniqueness_of :name, :scope => :year, + validates :name, :uniqueness => true, :scope => :year, :message => "should happen once per year" end </ruby> @@ -400,7 +400,7 @@ There is also a +:case_sensitive+ option that you can use to define whether the <ruby> class Person < ActiveRecord::Base - validates_uniqueness_of :name, :case_sensitive => false + validates :name, :uniqueness => true, :case_sensitive => false end </ruby> @@ -503,7 +503,7 @@ The +:on+ option lets you specify when the validation should happen. The default <ruby> 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 |