【发布时间】:2014-12-10 04:08:07
【问题描述】:
我的模型:
class Item < ActiveRecord::Base
belongs_to :group
scope :able, ->{joins(:group).where(:groups => {:disabled => [nil,false]}).order("position")}
end
class Group < ActiveRecord::Base
has_many :items
scope :able, ->{ where(disabled: [false,nil]).order('position') }
end
我的 item_index.rb
ThinkingSphinx::Index.define :item, :with => :active_record do
indexes title
# attributes
has created_at, updated_at, group_id, position
end
我如何仅索引 group.disabled 为 false 或 nil 的项目。
示例:
ThinkingSphinx::Index.define :item, :with => :active_record do
where "id = 1"
indexes title
# attributes
has created_at, updated_at, group_id, position
end
这将只索引 id = 1 的项目
【问题讨论】:
标签: ruby-on-rails thinking-sphinx