-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
The doc page that discusses relation validations says that Mongoid validates child relations by default (IE: has_one, has_many, embeds_one, etc). I'm finding that parent relations are also validated by default:
class Parent include Mongoid::Document has_many :children def valid?(*args) puts '*** Parent#valid?' super end end class Child include Mongoid::Document belongs_to :parent def valid?(*args) puts '*** Child#valid?' super end end Child.reflect_on_association(:parent).validate? => true p = Parent.new c = Child.new :parent => p c.valid? *** Child#valid? *** Parent#valid? => true
Is this the desired behaviour?