Ok, I have an really weird update:
My models are already updated, so they all have a sugar_level
attribute
and no taste anymore...
class Kind
include MongoMapper::EmbeddedDocument
key :color, String
key :rating, String
key :sugar_level, String
belongs_to :wagon
end
The mongoDB still holds the taste attribute for all records.
I tried to clone a kind document and save it in a temp object.
Let us assume the icecreamman only has one "kind".
Code is better than words:
man = IcecreamMan.first
temp = man.wagon.kinds.first.clone
man.wagon.kinds = []
man.save
new_kind = Kind.new(:color => temp.color, :rating =>
temp.rating, :sugar_level => temp.taste) #everything fine so far
man.wagon.kinds <<
new_kind
# new_kind doesn't have a taste attribute
man.save
# valid and saving
man.reload.wagon.kinds.first # taste attribute is back and nil
Everything works fine. When I reload the document, the nasty 'taste'
attribute is back and set to nil.
Kind.new doesn't have a 'taste' attribute. Now I am really stuck.
On Aug 23, 10:40 am, Clint <
simon.krollpfei...@gmail.com> wrote:
> Thank you for your reply Scott. The problem is, that I have an array
> of embedded documents.
> Reaching into a normal embedded document is no problem, but an
> array ...
>
> I don't think this is solvable with MongoMapper alone, so using raw
> MongoDB-Queries is a given.
> After trying a lot of different approaches, I stumbled upon this
> ticket:
http://groups.google.com/group/mongodb-user/browse_thread/thread/db51...