-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
This scenario fails with a cryptic error:
NoMethodError: undefined method `each' for 2013-05-30 00:43:26 UTC:Time
C:/ruby/lib/ruby/gems/1.9.1/gems/mongoid-3.1.4/lib/mongoid/atomic/modifiers.rb:121:in `add_operation'
require 'spec_helper' describe Mongoid::History do class Post include Mongoid::Document include Mongoid::Timestamps field :title embeds_many :tags, :cascade_callbacks => true accepts_nested_attributes_for :tags, :allow_destroy => true end class Tag include Mongoid::Document include Mongoid::Timestamps field :title end before(:each) do @post= Post.create(:title => "Test") @tag_bar = @post.tags.create(:title => "bar") end it "should allow an update through the parent model" do update_hash = { "post" => { "tags_attributes" => { "1234" => { "id" => @tag_bar.id, "title" => "baz" } } } } @post.update_attributes(update_hash["post"]) @post.tags.last.title.should == "baz" end end
Two things seem to fix it:
- Remove include Mongoid::Timestamps from Tag class OR
- Remove :cascade_callbacks => true from embeds_many :tags