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"] ```
1.6 KiB
1.6 KiB
-
Fix to working before/after validation callbacks on multiple contexts.
Yoshiyuki Hirano
Rails 5.2.0.beta2 (November 28, 2017)
- No changes.
Rails 5.2.0.beta1 (November 27, 2017)
-
Execute
ConfirmationValidator
validation when_confirmation
's value isfalse
.bogdanvlviv
-
Allow passing a Proc or Symbol to length validator options.
Matt Rohrer
-
Add method
#merge!
forActiveModel::Errors
.Jahfer Husain
-
Fix regression in numericality validator when comparing Decimal and Float input values with more scale than the schema.
Bradley Priest
-
Fix methods
#keys
,#values
inActiveModel::Errors
.Change
#keys
to only return the keys that don't have empty messages.Change
#values
to only return the not empty values.Example:
# Before person = Person.new person.errors.keys # => [] person.errors.values # => [] person.errors.messages # => {} person.errors[:name] # => [] person.errors.messages # => {:name => []} person.errors.keys # => [:name] person.errors.values # => [[]] # After person = Person.new person.errors.keys # => [] person.errors.values # => [] person.errors.messages # => {} person.errors[:name] # => [] person.errors.messages # => {:name => []} person.errors.keys # => [] person.errors.values # => []
bogdanvlviv
Please check 5-1-stable for previous changes.