Skip to content

Commit

Permalink
user-has-many-joined-projects
Browse files Browse the repository at this point in the history
And in the User model (remember that User already has an association called `projects` so we need a new name):

SHOW_PATCH
  • Loading branch information
bryanlarsen authored and iox committed Aug 12, 2013
1 parent 2286479 commit b390728
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/user.rb
Expand Up @@ -15,6 +15,8 @@ class User < ActiveRecord::Base
has_many :task_assignments, :dependent => :destroy, :inverse_of => :user
has_many :tasks, :through => :task_assignments
has_many :projects, :class_name => "Project", :foreign_key => "owner_id", :inverse_of => :owner
has_many :project_memberships, :dependent => :destroy, :inverse_of => :user
has_many :joined_projects, :through => :project_memberships, :source => :project

# This gives admin rights and an :active state to the first sign-up.
# Just remove it if you don't want that
Expand Down

0 comments on commit b390728

Please sign in to comment.