Seems like dm-is-tree does all this and more, so best to use this.... http://github.com/datamapper/dm-is-tree
DAZ On Oct 24, 5:57 pm, DAZ <[email protected]> wrote: > Hi, > > I'm trying to create some pages that can have child pages. Here is my > Page class: > > class Page > include DataMapper::Resource > property :id, Serial > property :title, String, :required => true > property :content, Text > > belongs_to :parent, self, :key => true > has n, :children, self, :child_key => [:parent_id] > end > > I'm testing this in a console and getting the following: > > > test = Page.new > > => #<Page @id=nil @title=nil @content=nil @parent_id=nil> > > >test.title = "Test" > > => "Test" > > > test.children > > => [] > > > test.parent > > => nil > > >test.save > > => false > > It all seems to be working fine, but won't save the page. Does anybody > have any ideas what I'm doing wrong here that is stopping it saving? > > cheers, > > DAZ -- 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.
