Skip to content

Instantly share code, notes, and snippets.

@vsevolod
Last active October 1, 2019 16:07
Show Gist options
  • Save vsevolod/fe2e442826d7b5ce8dc3fd47e10038ce to your computer and use it in GitHub Desktop.
Save vsevolod/fe2e442826d7b5ce8dc3fd47e10038ce to your computer and use it in GitHub Desktop.
Try to repeat error for mongoid7
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'mongoid', '~> 7.0'
gem 'mongoid_relations_dirty_tracking', github: 'tablecheck/mongoid_relations_dirty_tracking'
gem 'pry-byebug'
end
Mongoid.configure do |config|
config.clients.default = {
hosts: ['mongo:27017'],
database: 'test_db',
}
config.log_level = :warn
end
class Article
include Mongoid::Document
include Mongoid::RelationsDirtyTracking
embeds_many :comments, as: :commentable, class_name: 'Comment'
field :title
end
class Comment
include Mongoid::Document
embedded_in :commentable, polymorphic: true
field :text
end
article = Article.new(title: "MainArticle")
article.comments << Comment.new(text: "Some_text1")
article.comments << Comment.new(text: "Some_text2")
article.comments << Comment.new(text: "Some_text3")
article.save!
article.comments.first.assign_attributes(text: "Other_text")
article.save!
@vsevolod
Copy link
Author

vsevolod commented Oct 1, 2019

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment