mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
470d0e459f
I found a bug that validation callbacks don't fire on multiple context. So I've fixed it. Example: ```ruby class Dog include ActiveModel::Validations include ActiveModel::Validations::Callbacks attr_accessor :history def initialize @history = [] end before_validation :set_before_validation_on_a, on: :a before_validation :set_before_validation_on_b, on: :b after_validation :set_after_validation_on_a, on: :a after_validation :set_after_validation_on_b, on: :b def set_before_validation_on_a; history << "before_validation on a"; end def set_before_validation_on_b; history << "before_validation on b"; end def set_after_validation_on_a; history << "after_validation on a" ; end def set_after_validation_on_b; history << "after_validation on b" ; end end ``` Before: ``` d = Dog.new d.valid?([:a, :b]) d.history # [] ``` After: ``` d = Dog.new d.valid?([:a, :b]) d.history # ["before_validation on a", "before_validation on b", "after_validation on a", "after_validation on b"] ``` |
||
---|---|---|
.. | ||
attribute | ||
attribute_set | ||
locale | ||
serializers | ||
type | ||
validations | ||
attribute.rb | ||
attribute_assignment.rb | ||
attribute_methods.rb | ||
attribute_mutation_tracker.rb | ||
attribute_set.rb | ||
attributes.rb | ||
callbacks.rb | ||
conversion.rb | ||
dirty.rb | ||
errors.rb | ||
forbidden_attributes_protection.rb | ||
gem_version.rb | ||
lint.rb | ||
model.rb | ||
naming.rb | ||
railtie.rb | ||
secure_password.rb | ||
serialization.rb | ||
translation.rb | ||
type.rb | ||
validations.rb | ||
validator.rb | ||
version.rb |