From 279113f9b31ba6f08ba2489f5f033d269b94f829 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 23 Jun 2007 17:01:00 +0000 Subject: Fixed validates_associated should not stop on the first error (closes #4276) [mrj/manfred/josh] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7094 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/validations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 62946bd42c..c2f381e6d1 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -745,7 +745,7 @@ module ActiveRecord validates_each(attr_names, configuration) do |record, attr_name, value| record.errors.add(attr_name, configuration[:message]) unless - (value.is_a?(Array) ? value : [value]).all? { |r| r.nil? or r.valid? } + (value.is_a?(Array) ? value : [value]).inject(true) { |v, r| (r.nil? || r.valid?) && v } end end -- cgit v1.2.3