Skip to content

Instantly share code, notes, and snippets.

@sonianand11
Created April 26, 2013 05:29
Show Gist options
  • Save sonianand11/5465216 to your computer and use it in GitHub Desktop.
Save sonianand11/5465216 to your computer and use it in GitHub Desktop.
I want to create Task management app. Task has many assignee and one assignor. This is how I have created a association. Getting error of
ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :assignment in model User
class User < ActiveRecord::Base
attr_accessible :name
has_many :assignments,:foreign_key => "assignee_id"
has_many :tasks, :through => :assignment
end
class Task < ActiveRecord::Base
attr_accessible :name
has_many :assignments
end
class Assignment < ActiveRecord::Base
attr_accessible :task_id ,:assignee_id
belongs_to :assignee , :class_name => "User",:foreign_key => "user_id"
belongs_to :task
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment