Hi, I'm fairly new to RoR and I'm trying to figure out the best way to deal with Users in my application. I've got (for the purpose of this thread) 3 models, User, Subject, and SubjectUserAssignment.
The user model is joined to the Subject model with the following, creating a many to many relationship between User and Subject: has_many :subjects, :through => :subject_user_assignments has_many :subject_user_assignments Likewise, the Subject model: has_many :users, :through => :subject_user_assignments has_many :subject_user_assignments belongs_to :user, :foreign_key => "user_id_created" belongs_to :user, :foreign_key => "user_id_updated" This works fine, I can return all users for a given subject, and all subjects for a given user. The problem is that the Subject model has user_id_created and user_id_updated fields, which contain the user_id of the user(s) who created and updated the subject. So a user can either be related to a subject because they're assigned to it, or because they created/updated it, or both. How do I go about specifying this in my User model? User.subjects should return all subjects assigned to a user, but I need something else like User.created_subjects to show all subjects created by a user. Am I using :foreign_key correctly in the Subject model? -- 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 rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.