Minor refactoring of validates_associated to replace #inject with #collect + #all?

[#1686 state:committed]
This commit is contained in:
Josh Susser
2009-01-01 21:30:42 -08:00
committed by Michael Koziarski
parent 73cc5f270a
commit ccda96093a

View File

@@ -904,7 +904,7 @@ module ActiveRecord
configuration.update(attr_names.extract_options!)
validates_each(attr_names, configuration) do |record, attr_name, value|
unless (value.is_a?(Array) ? value : [value]).inject(true) { |v, r| (r.nil? || r.valid?) && v }
unless (value.is_a?(Array) ? value : [value]).collect { |r| r.nil? || r.valid? }.all?
record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value)
end
end