aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorEric Hutzelman <ehutzelman@gmail.com>2014-02-20 19:17:48 -0600
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-02-26 21:35:49 -0300
commit088c11658aa6b79d05e9014201d585c7700669aa (patch)
treebdd5f7b8ea4b0e4ad1bceb2bb33f94f4e970499d /activemodel/lib/active_model
parentc20fe91b0562987f5d9e57caee0bdbb6c9ef3220 (diff)
downloadrails-088c11658aa6b79d05e9014201d585c7700669aa.tar.gz
rails-088c11658aa6b79d05e9014201d585c7700669aa.tar.bz2
rails-088c11658aa6b79d05e9014201d585c7700669aa.zip
Fix some validators when used on model instance
Now that Validator #setup is called from the initializer, we need a reference to the model's class to be passed in to allow the validators to continue functioning when used at the instance level. Closes #14134.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/validations/with.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb
index 16bd6670d1..7022f9bee5 100644
--- a/activemodel/lib/active_model/validations/with.rb
+++ b/activemodel/lib/active_model/validations/with.rb
@@ -139,6 +139,8 @@ module ActiveModel
# class version of this method for more information.
def validates_with(*args, &block)
options = args.extract_options!
+ options[:class] = self.class
+
args.each do |klass|
validator = klass.new(options, &block)
validator.validate(self)