Might be a bug => http://pastie.org/796113
When I commented out that part in collection.rb that changes resource.collection to the collection itself it works fine. I didn't follow that into how Resource#collection works though, so my assessment is pretty shallow :) On Jan 26, 10:55 am, sfeu <sfeuerst...@gmail.com> wrote: > Hey, > > i got into trouble with datamapper recently when iterating over a list > that contains inherited resources. Can anyone please confirm this as a > bug or give me a hint what I am doing wrong? I expected the following > code to return all 5 "folders" which can be confirmed by executing > recursive(f). > > But instead after I saved and queried again, I only get 3 folders back > ( when executing recursive(d) ). > > Regards, > Sebastian > > require 'rubygems' > require 'dm-core' > > DataMapper.setup(:default, { :adapter => "in_memory" }) > > class Element > include DataMapper::Resource > property :id, Serial > property :name, String > property :classtype, Discriminator > belongs_to :folder > end > > class Folder < Element > has n, :elements > end > > f = Folder.new(:name =>"folder1", :elements =>[ > Folder.new > (:name=>"folder2", :elements => []), > Folder.new > (:name=>"folder3", :elements => [ > > Folder.new(:name=>"folder4", :elements => []), > > Folder.new(:name=>"folder5", :elements => []) > > ]) > ]) > > f.save > > def recursive (f) > p f.name > f.elements.each do |e| > recursive e > end > end > > d=Folder.first(:name =>"folder1") > > recursive(d) -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamap...@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.