aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/validations/associated.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-23 13:30:58 +0100
committerJosé Valim <jose.valim@gmail.com>2009-12-23 13:30:58 +0100
commit74098e4cb6de01745db8f1d8d567645553ade7c5 (patch)
tree61998222e5d362991d50fdb68153414848410ae2 /activerecord/lib/active_record/validations/associated.rb
parente31077c9aaec05bdf5ea0386eb42fcc039d86a0a (diff)
downloadrails-74098e4cb6de01745db8f1d8d567645553ade7c5.tar.gz
rails-74098e4cb6de01745db8f1d8d567645553ade7c5.tar.bz2
rails-74098e4cb6de01745db8f1d8d567645553ade7c5.zip
No need to use ValidationsRepairHelper hack on ActiveModel anymore, Model.reset_callbacks(:validate) is enough. However, tests in ActiveRecord are still coupled, so moved ValidationsRepairHelper back there.
Diffstat (limited to 'activerecord/lib/active_record/validations/associated.rb')
-rw-r--r--activerecord/lib/active_record/validations/associated.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations/associated.rb b/activerecord/lib/active_record/validations/associated.rb
index 6e6f4df415..66b78682ad 100644
--- a/activerecord/lib/active_record/validations/associated.rb
+++ b/activerecord/lib/active_record/validations/associated.rb
@@ -2,7 +2,7 @@ module ActiveRecord
module Validations
class AssociatedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- return if (value.is_a?(Array) ? value : [value]).compact.all?{ |r| r.valid? }
+ return if (value.is_a?(Array) ? value : [value]).collect{ |r| r.nil? || r.valid? }.all?
record.errors.add(attribute, :invalid, :default => options[:message], :value => value)
end
end