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

Deleting embedded document that lacks an "embedded_in" definition deletes the containing object

      Mongoid 3.1.0

      class User
      include Mongoid::Document
      embeds_many :labels
      end

      class Label
      include Mongoid::Document
      end

      class LabelsController < ApplicationController
      def destroy
      label = current_user.labels.find(params[:id])
      label.destroy
      end
      end

      For a label with id 'abc', calling DELETE /labels/abc destroys the current user.

      Changing the Label class to explicitly declare it "embedded_in :user" solves this problem, but it seems to me that deleting an embedded document should never result in deleting the containing document.

            Assignee:
            Unassigned Unassigned
            Reporter:
            daniel-nelson daniel-nelson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: