validates_confirmation_of only kicks in when the attribute, rather than its confirmation, is present. Closes #785.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4917 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
6d17ece9f2
commit
d9839c1952
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* validates_confirmation_of only kicks in when the attribute, rather than its confirmation, is present. #785 [z@wzph.com]
|
||||||
|
|
||||||
* to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher]
|
* to_xml: the :methods option works on arrays of records. #5845 [Josh Starcher]
|
||||||
|
|
||||||
* Deprecation: update docs. #5998 [jakob@mentalized.net, Kevin Clark]
|
* Deprecation: update docs. #5998 [jakob@mentalized.net, Kevin Clark]
|
||||||
|
|
|
@ -333,7 +333,8 @@ module ActiveRecord
|
||||||
attr_accessor *(attr_names.map { |n| "#{n}_confirmation" })
|
attr_accessor *(attr_names.map { |n| "#{n}_confirmation" })
|
||||||
|
|
||||||
validates_each(attr_names, configuration) do |record, attr_name, value|
|
validates_each(attr_names, configuration) do |record, attr_name, value|
|
||||||
record.errors.add(attr_name, configuration[:message]) unless record.send("#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation")
|
confirm = record.send("#{attr_name}_confirmation")
|
||||||
|
record.errors.add(attr_name, configuration[:message]) unless value.nil? || value == confirm
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue