Changed the Proc for a string to avoid repetition problems

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@96 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2004-12-09 14:04:58 +00:00
parent a65f791fbd
commit d33f814db5

View File

@@ -75,11 +75,9 @@ module ActiveRecord
def validate_confirmation(*attr_names)
for attr_name in attr_names
attr_accessor "#{attr_name}_confirmation"
class_eval <<-EOC
validate_on_create(Proc.new { |record|
record.errors.add("#{attr_name}", "doesn't match confirmation") unless record.#{attr_name} == record.#{attr_name}_confirmation
})
EOC
class_eval <<-EOM
validate_on_create %{errors.add('#{attr_name}', "doesn't match confirmation") unless #{attr_name} == #{attr_name}_confirmation}
EOM
end
end
end