Last active
October 1, 2019 16:07
-
-
Save vsevolod/fe2e442826d7b5ce8dc3fd47e10038ce to your computer and use it in GitHub Desktop.
Try to repeat error for mongoid7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed