File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -629,14 +629,23 @@ being operated on:
629629 }
630630
631631When defining a default value as a ``Proc``, Mongoid will apply the default
632- after all other attributes are set. To have the default be applied before
633- the other attributes are set, use the ``pre_processed: true`` field option:
632+ after all other attributes are set and associations are initialized.
633+ To have the default be applied before the other attributes are set,
634+ use the ``pre_processed: true`` field option:
634635
635636.. code-block:: ruby
636637
637638 field :fulfill_by, type: Time, default: ->{ Time.now + 3.days },
638639 pre_processed: true
639640
641+ The ``pre_processed: true`` option is also necessary when specifying a custom
642+ default value via a ``Proc`` for the ``_id`` field, to ensure the ``_id``
643+ is set correctly via associations:
644+
645+ .. code-block:: ruby
646+
647+ field :_id, type: String, default: -> { 'hello' }, pre_processed: true
648+
640649
641650.. _storage-field-names:
642651
You can’t perform that action at this time.
0 commit comments