- 
    Type:
Bug
 - 
    Resolution: Fixed
 - 
    Priority:
Unknown
 - 
    Affects Version/s: 8.0.3
 - 
    Component/s: None
 - 
    None
 
- 
        None
 
- 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 
The code below assumes that Post embeds many Comments:
post = Post.create! 10.times do |i| post.comments.create! end pp Post.collection.find().to_a.first['comments'].size # => 10 post.comments.delete(post.comments.first) pp Post.collection.find().to_a.first['comments'].size # => 9 post.comments.delete_one(post.comments.first) pp Post.collection.find().to_a.first['comments'].size # => 9
So, there is a difference in the behaviour of delete (persists changes to the database), and delete_one (does not persist the changes).
Further, there is delete_one method in the EmbedsMany::Proxy class; this method is private. However, it is not being called here; the method of Array extension is called instead.
We should investigate the situation and either prohibit calling delete_one on associations, or document make them behave in accordance with delete, or document the difference.
- backported by
 - 
                    
MONGOID-5620 Backport MONGOID-5560 to 8.0-stable and 8.1-stable
-         
 - Closed
 
 -