From 0fc9735137ae581c1205c3e145c6da22a77b407d Mon Sep 17 00:00:00 2001 From: Heitor Salazar Baldelli Date: Thu, 1 Aug 2013 16:21:40 -0300 Subject: [PATCH] Send object a message instead of directly setting the attribute This line will lead to fail when you have nested attributes in a document. Since the access to the property is made directly (throgh the #[] method) mongoid will store the association_attributes as a property of the document, instead of triggering the nested attributes generated method. This little patch fixes this issue. --- lib/seed-fu-mongoid/document_seeder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/seed-fu-mongoid/document_seeder.rb b/lib/seed-fu-mongoid/document_seeder.rb index efd7026..58dfec3 100644 --- a/lib/seed-fu-mongoid/document_seeder.rb +++ b/lib/seed-fu-mongoid/document_seeder.rb @@ -71,7 +71,7 @@ module SeedFuMongoid def seed! data.each do |key, value| - document[key] = value + document.send :"#{key}=", value end puts "#{@klass.name} #{document.attributes}" -- 2.45.2