Created
April 26, 2013 05:29
-
-
Save sonianand11/5465216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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