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.
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 Peter Michaux (Guest)
on 2006-01-15 22: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
E48d29dc8fedb2878fa518d41cc63d88?d=identicon&s=25 Jan Prill (Guest)
on 2006-01-15 22: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 Prill
Eecd295cdec2454c66e2015036a39408?d=identicon&s=25 scott (Guest)
on 2006-01-15 23: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 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
This topic is locked and can not be replied to.