diff options
author | Josh Susser <josh@hasmanythrough.com> | 2009-01-01 21:30:42 -0800 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-01-22 13:45:19 +1300 |
commit | ccda96093a3bf3fb360f7c6d61bbbf341b2ae034 (patch) | |
tree | e227f4abe00a75b11db9e33e3ce33c1c7348c240 | |
parent | 73cc5f270a5c2a2eab76c6c02615fec608822494 (diff) | |
download | rails-ccda96093a3bf3fb360f7c6d61bbbf341b2ae034.tar.gz rails-ccda96093a3bf3fb360f7c6d61bbbf341b2ae034.tar.bz2 rails-ccda96093a3bf3fb360f7c6d61bbbf341b2ae034.zip |
Minor refactoring of validates_associated to replace #inject with #collect + #all?
[#1686 state:committed]
-rw-r--r-- | activerecord/lib/active_record/validations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 6a9690ba85..6d750accb0 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -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 |