Skip to content

Commit

Permalink
Merge pull request mongodb#874 from nickhoffman/issue_836
Browse files Browse the repository at this point in the history
Deleting from a M-M reference is one-sided
  • Loading branch information
durran committed Jun 5, 2011
2 parents 5fbca70 + 6b88653 commit 0b34731
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/mongoid/relations/referenced/many_to_many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def create!(attributes = nil, type = nil, &block)
def delete(document, options = {})
target.delete(document).tap do |doc|
binding.unbind_one(doc, default_options.merge!(options)) if doc
doc.save if doc && base.persisted? && !options[:binding]
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,11 @@
end

it "removes the inverse reference" do
deleted.people.should be_empty
deleted.reload.people.should be_empty
end

it "removes the base id from the inverse keys" do
deleted.person_ids.should be_empty
deleted.reload.person_ids.should be_empty
end


Expand Down

0 comments on commit 0b34731

Please sign in to comment.