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

Adding duplicated entries on HABTM array (Hash backed-enumerable targets)

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

      Hi

      Suppose I have this models:

      class Post
        include Mongoid::Document
      
        has_and_belongs_to_many :categories 
      end
      
      class Category
        include Mongoid::Document
        field :name
      
        has_and_belongs_to_many :posts
      end
      

      After my upgrade to the current commit on 2.2.0-stable branch (I had to upgrade to this version because of the fix of MONGOID-1226), this test failed:

      category = Category.create(:name => "MyCategory")
      post = Post.new
      
      post.categories = [category, category]
      post.save!
      
      post.categories.should == [category]
      

      We got two elements on categories, both with the same id.

      Is this expected ?

            Assignee:
            durran Durran Jordan
            Reporter:
            rodrigoflores rodrigoflores
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: