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

Exception raised after DB operation succeeds with :has_and_belongs_to_many

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I have has_and_belongs_to_many :items, inverse_of: nil, validate: false on my model.

      When I do add_to_set(:items, new_item), I see the following in the DB:

      MOPED: 127.0.0.1:27017 UPDATE       database=development collection=things selector={"_id"=>"50fc9e52679d6b729500001a"} update={"$addToSet"=>{"item_ids"=>"50fc9f64679d6b1a3000002d"}} flags=[] (0.0682ms)
      

      So far so good.

      The problem is, as soon as this operation completes, I get a bizarre {{NoMethodError (undefined method }}each' for 2013-01-21 01:51:03 UTC:Time):{{ exception even though I don't have }}each{{ in my code. The exception appears to be coming from the conversion of }}new_item{{'s value to }}:items`

            Assignee:
            Unassigned Unassigned
            Reporter:
            emirkin Eugene Mirkin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: