In my model I have a user. The user is the athlete. A user may also be a coach to any other user. How to model this?
I have:
@user.coach? => true/false
@user.is_a_coach_of?(other_user) => true/false
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If a user can only have one coach, then you can have a coach association on the users table back to the users table. The classic example of this is an employees table, where every employee has exactly one manager (except the CEO).
If a user could have many coaches, then use a coaches table, with fields, user_id (for the coach) and coachee_id for the user that she coaches.