Hello, I have a problem with a little more complex DB-schema. My target are and sorted trees like this: 1 One 1.1 One.One 1.2 One.Two 2 Two I use for it two models: - top: This an item, with the name and position - agenda: Collections of tops class Agenda < ActiveRecord::Base has_and_belongs_to_many :tops end class Top < ActiveRecord::Base has_and_belongs_to_many :agendas acts_as_list :scope => :parent_id acts_as_tree :order => :position end Datebase tops: id | parent_id | position | title 1 | 0 | 1 | One 2 | 0 | 2 | Two 3 | 1 | 1 | One.One 4 | 1 | 2 | One.Two Looks like: http://www.valibuk.net/?p=42 Works fine. But my problem: The tops-database include tops for all agendas. So a second agenda need also a new top with parent_id=0 and position=1: 5 | 0 | 1 | New One ... but acts_as_list used (sadly) correctly parent_id=0 and position=3 Result: acts_as_list :scope => :parent_id + "correct agendas" Which scope-option I need? Anyone can me help with the SQL-statement? Or I must used acts_as_nested_set? Never used it. But there the same problem with :scope and habtm-relationship, I think. Thanks for help Martin
on 2007-07-17 23:34
on 2007-07-20 19:40
Martin schrieb: > I have a problem with a little more complex DB-schema. Anybody an idea?