浏览 281 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2008-05-29 关键字: has_many through hasmanythroughsourceassociationnotfounderr
class Chatroom < ActiveRecord::Base
has_many :replies has_many :discussants has_many :users, :through => :discussants has_many :comperes, :through => :discussants, :class_name => "User", :conditions => ['role = 6'] end 视图里调用users是正常的,但调用comperes出错,提示 ActiveRecord::HasManyThroughSourceAssociationNotFoundError in Chatrooms#index Showing chatrooms/index.html.erb where line #11 raised: Could not find the source association(s) :compere or :comperes in model Discussant. Try 'has_many :comperes, :through => :discussants, :source => <name>'. Is it one of :chatroom or :user? 一个开源项目里用同样的示例运行也有问题。 rails2.0 ruby1.8 Mongrel 1.1.2 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2008-05-29
你按他的提示做试试。
has_many :comperes, :through => :discussants, :source => :user, :conditions => ['role = 6'] |
|
| 返回顶楼 | |
|
最后更新时间:2008-05-29
奇怪原来试过不行,现在又试了一遍,又可以了。:)
|
|
| 返回顶楼 | |




