Permalink
Browse files

Remove unnecessary loop in validates_presence_of. [sur] Closes #9392

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7362 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
NZKoz committed Aug 28, 2007
1 parent 016947c commit 5cbc782ecef16f256f543fa444dc1380925cefc0
Showing with 5 additions and 7 deletions.
  1. +5 −7 activerecord/lib/active_record/validations.rb
@@ -490,13 +490,11 @@ def validates_presence_of(*attr_names)
# can't use validates_each here, because it cannot cope with nonexistent attributes,
# while errors.add_on_empty can
- attr_names.each do |attr_name|
- send(validation_method(configuration[:on])) do |record|
- unless (configuration[:if] && !evaluate_condition(configuration[:if], record)) || (configuration[:unless] && evaluate_condition(configuration[:unless], record))
- record.errors.add_on_blank(attr_name,configuration[:message])
- end
- end
- end
+ send(validation_method(configuration[:on])) do |record|
+ unless (configuration[:if] && !evaluate_condition(configuration[:if], record)) || (configuration[:unless] && evaluate_condition(configuration[:unless], record))
+ record.errors.add_on_blank(attr_names, configuration[:message])
+ end
+ end
end
# Validates that the specified attribute matches the length restrictions supplied. Only one option can be used at a time:

0 comments on commit 5cbc782

Please sign in to comment.