Modeling unknown # of Departments/Sections in Ruby on Rails

67 Views Asked by At

In Ruby on Rails, how can you model a situation where an Employee may belong to a Section and that Section may or may not belong to another Section all the way up to Organization. I am looking for a set of models that can handle an unknown number of levels. And then finding out the most immediate level an Employee is in, and each Section would have it's own admin(s).

I hope to use acl9 for authorization, but still can't figure out how this would be done if the number of levels is unknown.

1

There are 1 best solutions below

1
On BEST ANSWER

The ancestry gem sounds like it might do what you are looking for. There's a railscast on it as well: http://railscasts.com/episodes/262-trees-with-ancestry