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

relations should raise more helpful error if something other than a BSON::ObjectID or strings convertible to it is added to the relation

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.2.1
    • Affects Version/s: None
    • Component/s: None

      Consider the following (corrupt ) param that came into my controller#create method from a select box in the form:

      ["[\"4e4d58b73f1514345f000058\"]"]

      I'm trying to figure out why I'm getting this, although clearly, it isn't Mongoid's fault. However, it's pretty easy through mass assignment, or whatever, for this junk to slip through and be added to the relation array for an object. The result is the following error: undefined method `in_memory' for #<Array:0x0000010959f8d0>. It seems to me that Mongoid should raise a more appropriate error message. While it isn't Mongoid's fault that this junk came in the door, it is a foreseeable event. It was also really nasty to debug. In my case, the request even looked fine in the console.

      Thanks,
      Paul

            Assignee:
            Unassigned Unassigned
            Reporter:
            hamannp hamannp
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: