Forum: Ruby on Rails acts_as_tree & acts_as_list for a single model?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Peter M. (Guest)
on 2006-01-15 23:44
(Received via mailing list)
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
Jan P. (Guest)
on 2006-01-15 23:53
(Received via mailing list)
Hi, Peter,

yes you could do that. I'm doing it in one of my models without a
problem.

Best Regards
Jan P.
scott (Guest)
on 2006-01-16 00:59
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 M. 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
This topic is locked and can not be replied to.