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

Embed documents cannot save when using 'with' method specify collection name

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 5.1.4
    • Component/s: None
    • None
    • Environment:
      MongoDB server v3.2.1

      class Post
        include Mongoid::Document
      
        embeds_many :comments
      end
      
      class Comment
        include Mongoid::Document
      
        field :content, type: String
        embedded_in :post
      end
      
      # query existing post
      post = Post.with(collection: 'posts_2016').first
      post.comments.build(content: '....')
      post.with(collection: 'posts_2016').save!
      
      # but save don't work, 
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            bastengao bastengao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: