现在几个小时我试图让sphinx示波器工作失败。
我想要范围ActsAsTaggableOn的标签。在我的模型中(可标记)我尝试了以下范围:
# This normal scope works
scope :tagged, lambda {
joins(:taggings => :tag).
where("tags.name = 'consequatur'")
}
# fails! (can't convert ActiveRecord::Relation into Hash)
sphinx_scope :tagged do
joins(:taggings => :tag).
where("tags.name = 'consequatur'")
end
对旧条件的另一次尝试:
# works with normal scope (returns one record)
scope :tagged, :joins => :taggings, :conditions => {"taggings.tag_id" => 74}
# fails! (returns nothing)
sphinx_scope(:tagged) do
{:joins => :taggings, :conditions => {"taggings.tag_id" => 74}}
end
如何使这些范围有效?是否有其他方式来存档该任务?我想只搜索那些用特定标签标记的模型。