It’s been a while since i’ve been doing any rails development, so i’m a
bit rusty. Having found this:
it looks really interesting and useful for solving something i’m trying
to get working.
What i have (essentially) is the following models:
class Group < ActiveRecord::Base
has_many :users, :through => :memberships
belongs_to :owner, :class_name => “User”
class Membership < ActiveRecord::Base
class User < ActiveRecord::Base
has_many :groups, :through => :memberships
Now then, what i’d like to know is how do i go about finding all the
Users contained within a nested set?
admins = Group.find_by_name “admins”
admins.users # gives all users in the admins group.
admins.all_children # gives me all the groups
I thought the following methods sounded promising, but i get
NoMethodError’s from them:
Perhaps i’m going about this the wrong way or i’m missing a more obvious
solution. Can anyone shed some light on it?