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 P.

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs