-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Associations
Greetings,
Adding a document to an embeds_many does not updated the parent's .updated_at. This example adds a child document, and saves the parent document. The updated_at field does not change. I am using "master"'s copy from today.
This issue is similar to https://github.com/mongoid/mongoid/issues/1551
require 'mongoid' Mongoid.load!('config/mongoid.yml', :test) # the big container object class Book include Mongoid::Document include Mongoid::Timestamps embeds_many :notes end # the template "note" class Note include Mongoid::Document embedded_in :book field :message, :type => String end puts '--- A blank object' book = Book.new book.save puts "Changed? #{book.changed?}" puts "Updated at: #{book.updated_at}" puts "Document looks like: #{book.as_document}" sleep 3 # terrible puts "\n\n" puts '--- Adding a note' book.notes << Note.new({ :message => 'Hello World!'}) book.save puts "Changed? #{book.changed?}" puts "Updated at: #{book.updated_at}" puts "Document looks like: #{book.as_document}"
Unable to find source-code formatter for language: text. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
[deployer@local current]$ bundle exec ruby test.rb --- A blank object Changed? false Updated at: 2013-09-04 00:03:23 UTC Document looks like: {"_id"=>"522678cb9f4a1aeae7000001", "updated_at"=>2013-09-04 00:03:23 UTC, "created_at"=>2013-09-04 00:03:23 UTC} --- Adding a note Changed? false Updated at: 2013-09-04 00:03:23 UTC Document looks like: {"_id"=>"522678cb9f4a1aeae7000001", "updated_at"=>2013-09-04 00:03:23 UTC, "created_at"=>2013-09-04 00:03:23 UTC, "notes"=>[{"_id"=>"522678ce9f4a1aeae7000002", "message"=>"Hello World!"}]}
Thank you!
- has to be done after
-
MONGOID-5016 Change the default of :touch option to true on embedded associations
- Closed
- links to