views:

55

answers:

1

Hi,

I'm building a simple project collaboration tool using rails 2.3. Authentication is handling with Restful Authentication plugin and for role management using Role Requirement plugin.

I need to create User collaboration. For example, when an authorized User logged in, User can create a team that belongs to User, so team can login and create/edit/update/delete User's data. So every User can create team for collaborate together.

I tried with Invitation model, in my try ; User can invite, another user (with invitation_id) then i filtered controllers/finders with (invitation_id). If invited User logs in, can only see inviter User's data. But thats not good for manageability and creates complex code base.

How can i implement like this user collaboration system ? so what is the best practice for it.

Thanks

+2  A: 

I would probably create a Collaboration or Project class that has_and_belongs_to_many users.

class Collaboration
  has_and_belongs_to_many :users
end

You could also set up distinct ActiveRecord relationships for the Collaboration owner and members (if that fits you business logic.)

e.g.

class Collaboration
  belongs_to :owner, :class_name => 'User'
  has_and_belongs_to_many :members, :class_name => 'User'
end

It's generally a best practice to keep as much of this logic out of the controllers (and in the models) as possible. See http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model.

samg