diff options
author | Subba Rao Pasupuleti <subbarao.pasupuleti@gmail.com> | 2010-08-31 17:57:39 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-01 14:00:26 +0200 |
commit | 0ae81a21243961f4d2481e9b87e3c807291d21a9 (patch) | |
tree | 7f8f2e49b28ec3ab8353fa445d17cad5b0e92744 /activemodel/lib | |
parent | 2d74ed49f4513572b102ce82696a6f62335a1841 (diff) | |
download | rails-0ae81a21243961f4d2481e9b87e3c807291d21a9.tar.gz rails-0ae81a21243961f4d2481e9b87e3c807291d21a9.tar.bz2 rails-0ae81a21243961f4d2481e9b87e3c807291d21a9.zip |
Refactoring conditional logic
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/validations/confirmation.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index a31966d0c2..2c8a840124 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -4,9 +4,9 @@ module ActiveModel module Validations class ConfirmationValidator < EachValidator def validate_each(record, attribute, value) - confirmed = record.send(:"#{attribute}_confirmation") - return if confirmed.nil? || value == confirmed - record.errors.add(attribute, :confirmation, options) + if (confirmed = record.send("#{attribute}_confirmation")) && (value != confirmed) + record.errors.add(attribute, :confirmation, options) + end end def setup(klass) |