• E
    validate related records in the same validation context as parent. · 9b15e01c
    Emmanuel Oga 提交于
    E.G.:
    
    ```ruby
    class Parent < ActiveRecord::Base
      has_one :child
      validates_presence_of :name, :on => "custom_context"
      validates_associated :child
    end
    
    class Child < ActiveRecord::Base
      belongs_to :parent
      validates_presence_of :name, :on => "custom_context"
    end
    
    p = Parent.new(:name => "Montoto", :child => Child.new)
    p.valid?(:custom_context) # => Returns true, even though the child is not valid under the same context.
    ```
    9b15e01c
association_validation_test.rb 4.8 KB