aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-09-08 10:10:14 -0500
committerJoshua Peek <josh@joshpeek.com>2009-09-08 10:26:39 -0500
commit4f37b97033f596ec2c95eb53e9964e051c224981 (patch)
treeb7dd859f4d1b1835178eec795711f8619963c23c /activemodel/lib/active_model/validations
parentaeab739bd56c0bff6d1b5685eee35e557484ab4c (diff)
downloadrails-4f37b97033f596ec2c95eb53e9964e051c224981.tar.gz
rails-4f37b97033f596ec2c95eb53e9964e051c224981.tar.bz2
rails-4f37b97033f596ec2c95eb53e9964e051c224981.zip
Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r--activemodel/lib/active_model/validations/presence.rb2
-rw-r--r--activemodel/lib/active_model/validations/with.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb
index 72d6b1c6f0..3ff677c137 100644
--- a/activemodel/lib/active_model/validations/presence.rb
+++ b/activemodel/lib/active_model/validations/presence.rb
@@ -32,7 +32,7 @@ module ActiveModel
# can't use validates_each here, because it cannot cope with nonexistent attributes,
# while errors.add_on_empty can
- send(validation_method(configuration[:on]), configuration) do |record|
+ validate configuration do |record|
record.errors.add_on_blank(attr_names, configuration[:message])
end
end
diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb
index 851cdfebf0..edc2133ddc 100644
--- a/activemodel/lib/active_model/validations/with.rb
+++ b/activemodel/lib/active_model/validations/with.rb
@@ -51,7 +51,7 @@ module ActiveModel
def validates_with(*args)
configuration = args.extract_options!
- send(validation_method(configuration[:on]), configuration) do |record|
+ validate configuration do |record|
args.each do |klass|
klass.new(record, configuration.except(:on, :if, :unless)).validate
end