Forum: Ruby on Rails Ordering of subsets in a model.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mathias W. (Guest)
on 2006-05-10 05:33
(Received via mailing list)
Alright, I got this table with lots of entries for menus. There's
several menus (with their own model since each menu got some special
information). Now, I want to be able to specify the order of the menu
entries inside the menu. acts_as_list seems to not quite do the trick
since it does ordering "globally" on the whole model and
acts_as_nested_set seems like overkill since I'm never going to need
more then one menu's entries at a time.

Should I got for acts_as_nested_set or should I simply create my own
ordering system with a column and some checks that makes sure no
numbers are repeated inside each menu's entries? I have a feeling
there is a nice and good solution lurking out there though.

I hope I'm making any sense, kinda late, but I was hoping for some
good answers to read tomorrow morning.

Daniel -. (Guest)
on 2006-05-10 05:39
(Received via mailing list)
You could use acts_as_list :scope => :menu_id

This way the scope for the list is set to be within only the menu that
item belongs to.  Each menu has another list.
Mathias W. (Guest)
on 2006-05-10 17:07
(Received via mailing list)
Beautiful. I had a feeling I was overlooking something that would do
exactly what I wanted.

Muchos gracias! :D

This topic is locked and can not be replied to.