diff options
Diffstat (limited to 'activemodel/lib/active_model/validations.rb')
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index d460068830..ae1d69f685 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -49,8 +49,7 @@ module ActiveModel private :validation_context= define_callbacks :validate, scope: :name - class_attribute :_validators, instance_writer: false - self._validators = Hash.new { |h, k| h[k] = [] } + class_attribute :_validators, instance_writer: false, default: Hash.new { |h, k| h[k] = [] } end module ClassMethods @@ -147,6 +146,9 @@ module ActiveModel # or <tt>unless: Proc.new { |user| user.signup_step <= 2 }</tt>). The # method, proc or string should return or evaluate to a +true+ or +false+ # value. + # + # NOTE: Calling +validate+ multiple times on the same method will overwrite previous definitions. + # def validate(*args, &block) options = args.extract_options! @@ -432,4 +434,4 @@ module ActiveModel end end -Dir[File.dirname(__FILE__) + "/validations/*.rb"].each { |file| require file } +Dir[File.expand_path("validations/*.rb", __dir__)].each { |file| require file } |