Peter Michaux
2006-Jan-15 21:43 UTC
[Rails] acts_as_tree & acts_as_list for a single model?
Hi, If I have a db table categories - id - name - parent_id - position is it alright to have the Category model act_as_tree and for each level act_as_list? class Category < ActiveRecord::Base acts_as_tree :order => :position acts_as_list :scope => :parent_id end Thanks, Peter
Hi, Peter, yes you could do that. I''m doing it in one of my models without a problem. Best Regards Jan Prill Peter Michaux wrote:> Hi, > > If I have a db table > > categories > - id > - name > - parent_id > - position > > is it alright to have the Category model act_as_tree and for each > level act_as_list? > > class Category < ActiveRecord::Base > acts_as_tree :order => :position > acts_as_list :scope => :parent_id > end > > Thanks, > Peter > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
I had some trouble with this when I tried it. See: http://forum.textdrive.com/viewtopic.php?id=7639 I still haven''t figured out how to get it to work right. If you get it to work, let me know. Peter Michaux wrote:> Hi, > > If I have a db table > > categories > - id > - name > - parent_id > - position > > is it alright to have the Category model act_as_tree and for each > level act_as_list? > > class Category < ActiveRecord::Base > acts_as_tree :order => :position > acts_as_list :scope => :parent_id > end > > Thanks, > Peter-- Posted via http://www.ruby-forum.com/.