-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
The patch for issue MONGOID-1676 changed the behavior of the presence validator so that it enables autosave on the relation. However, there are circumstances where this is undesirable. The only way to get around this it to assign the presence validator before the relation which is a bit clunky.
This patch allows you to explicitly set the autosave field on the relation to false to disable this behavior. If you do not specify anything for autosave, or set it to true, it will apply the current behavior. For example:
class Tag include Mongoid::Document belongs_to :post end class Post include Mongoid::Document has_many :tags, autosave: false validates_presence_of :tags # does not enable autosave on tags end