Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5331

Document hash assignment to associations

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 8.1.0
    • Affects Version/s: None
    • Component/s: Associations, Docs
    • None
    • Fully Compatible

      Mongoid permits hash to be assigned to an association like so:

                     band.manager = {name: 'boss'}
      

      This behavior does not exist in Rails and appears to be undocumented in Mongoid. It should be documented in the reference somewhere.

      Additionally, the substitute method as per the comment in https://github.com/mongodb/mongoid/pull/5232 has incorrect docstring: it claims that replacement is a Document but it can be a Hash as per this ticket. Correcting that docstring is also in scope of this ticket.

      Test and update all of the substitute methods to see if they can take hashes
      Test and update all of the batchable methods to see if they can take hashes as well.

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: