我正在关注Michael Hartl的rails book并收到以下错误消息:
python -m SimpleHTTPServer
调用ActiveRecord::HasManyThroughSourceAssociationNotFoundError: Could not find the source association(s) :follower in model Relationship. Try 'has_many :following, :through => :active_relationships, :source => <name>'. Is it one of ?
时(其中michael.follower
是用户对象)。
以下是关联:
michael
答案 0 :(得分:0)
如果我理解正确,你会通过关系模型在用户和关系模型之间建立多对多的关系(我很抱歉同义词)。
我建议改变
has_many :following, :through => :active_relationships, source: :follower
has_many :followers, :through => :passive_relationships, source: :followed
到
has_many :following, :through => :active_relationships, class_name: "User"
has_many :followers, :through => :passive_relationships, class_name: "User"