Acts as list with a subgroup

145 views Asked by At

I'm using the popular gem, acts_as_list and I am having issue with getting the scope to work. Basically there're three models, a group, a subgroup, and a thing. A group has many subgroups and a subgroup has many things. Is it possible to make the gem work without having to make the thing know what group it is on if these need to be ordered within the context of the group and not the subgroup? Basically I don't want to add a group_id to the things table as the things table can already calculate what group it belongs to based on it's subgroup_id

1

There are 1 answers

2
Brendon Muir On

Have you tried a has_many through: for the grandparent relationship from the grandchild, then using this as the scope?

You could also try adding a default_scope that selects the grandparent_id as an extra field in the results, then using that field in your scope?