nobosh wrote:
> Guys, I appreciate the replies but I'm not trying to assign roles to
> users.
> 
> Users can join projects, and users have roles per project
> 
> Examples:
> User X belong to Project A with an Admin Role
> User X belong to Project B with an Guest Role
> User Y belong to Project B with an Observer Role
> 
> Does that help clear out why I can't use a bitmask on the user's
> table?

What I think I would do for this would be along the lines of

class User < AR::B
  has_many :permissions
  has_many :projects, :through => :permissions
end

class Project < AR::B
  has_many :permissions
  has_many :users, :through => :permissions
end

class Role < AR::B
  has_many :permissions
end

class Permission < AR::B
  belongs_to :user
  belongs_to :project
  belongs_to :role
end

...so that Permission is at the center of a Y-shaped relationship.  Does 
that help?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to