aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-11-05 20:43:04 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-11-05 20:43:04 +0530
commit09298e42578740094130f4a6536b944a7733d7f1 (patch)
tree96fe75dc4fc1047f65c443f3d46b10ba31634c0e
parent53f61acdcad51e28b36f41c0af3c7c1fb8078c10 (diff)
downloadrails-09298e42578740094130f4a6536b944a7733d7f1.tar.gz
rails-09298e42578740094130f4a6536b944a7733d7f1.tar.bz2
rails-09298e42578740094130f4a6536b944a7733d7f1.zip
Revert "outline two ways to invoke a custom active model validator"
This reverts commit d163d3bf7ebb98d90977974aed8f85b7ec678afd. Reason: The alternate approach can be documented in the guide and not disrupt the existing flow in the readme.
-rw-r--r--activemodel/README.rdoc10
1 files changed, 1 insertions, 9 deletions
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index fa3353a780..67701bc422 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -162,21 +162,13 @@ modules:
{Learn more}[link:classes/ActiveModel/Validations.html]
* Custom validators
-
- class Person
- include ActiveModel::Validations
- validates_with HasNameValidator
- attr_accessor :name
- end
class Person
include ActiveModel::Validations
- validates :name, :has_name => true
+ validates_with HasNameValidator
attr_accessor :name
end
- You could use any of the two ways mentioned above to use a Custom Validator.
-
class HasNameValidator < ActiveModel::Validator
def validate(record)
record.errors[:name] = "must exist" if record.name.blank?