Hey, Here's a gist that I think shows what you need:
http://gist.github.com/622002 I hope this helps. Cheers, # solnic On Oct 12, 11:56 am, sfeu <[email protected]> wrote: > Hey everybody, > > still have lots of problems with my associations that are not saved > corectly. > > I am using a lot of nested file/folder type structures like the > following and > i really want to understand why i am unable to save the parent > relationship? > > Thanks, > Sebastian > > class File > include DataMapper::Resource > property :id, Serial > property :classtype, Discriminator > property :name, String > has 1, :parent, self > end > > class Folder < File > has n, :childs, File > end > > file = File.new(:name=>"File") > folder = Folder.new(:name=>"Folder", :childs =>[file]) > > file.parent = folder > > folder.childs[0].parent.name.should =="Folder" # works > > folder.save! > > Folder.first(:name=>"Folder").childs[0].parent # gives nil > > File.first(:name=>"File").parent # gives nil -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
