I am using the ancestry gem in my rails project to create a hierarchy of groups. A group can belong to a parent group and can have many children groups. Each group can have many users who belong to a group. The model looks like this:
class Group < ActiveRecord::Base
has_ancestry
has_many :users
end
I would love to be able to get all users for the descendants of a group, something like this:
class Group < ActiveRecord::Base
has_ancestry
has_many :users
has_many :descendants_users, through: :descendants
end
which, of course, doesn't work.
Any suggestions?