[Rails] Newbie Associations Design Question
Hello
I am new to rails and have a design issue. Although I have a proposed
solution I am far from sure how robust it is. I would appreciate any
feedback.
My application is team based:
- A user can only be in one team
- Team members(user) cannot view/edit another team's content
Team A
-User
-Widget
--Part
Team B
-User
-Widget
--Part
I need to:
- identify the team from the user
- create members for a team
So everything is simple - just create a User model that belongs_to the
Team (has_many users). Except I need admin users to manage the teams. My
problem is how best to manage this?
I think I need a User model and a Member model. The user handles
authentication, a user without a member association is an admin and the
member belongs to the Team. Perhaps something like this:
Team
has_many :members
Member
belongs_to :team
has_one :user
attr :team_role
User
belongs_to: member
authenticates!
attr :admin_role
However, this doesn't seem correct because the User still belongs to
Team. I am sure that at least the relationship between user & member is
incorrect. Can you suggest a better (more conventional) solution?
Many Thanks
Polly
--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home