0
我有一个模型是这样的:条件关系
Stem
-id
-etc
然后,我有
Stemrelation
-stem_id
-related_stem_id
-active
我可以得到下面的关系相关的茎
class Stem < ActiveRecord::Base
has_many :stemrelations
has_many :related_stems, :through => :stemrelations
end
class Stemrelation < ActiveRecord::Base
belongs_to :stem
belongs_to :related_stem, :class_name => "Stem", :foreign_key => "related_stem_id"
end
但现在我只想得到积极的关系。
我尝试添加这对干型号:
has_many :active_related, :through => :stemrelations, :source => :related_stem, :conditions => {:active => true}
但becasue它试图检查活动标志的干模型,而不是stemrelation这给了我一个错误。我在这里改变什么?
谢谢!