1
내 모델 : 난 인덱스에만 항목 group.disabled 수있는 방법생각 스핑크스 인덱서 조건
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
는 허위 또는 전무하다. 경우에
는예 : ID로
ThinkingSphinx::Index.define :item, :with => :active_record do
where "id = 1"
indexes title
# attributes
has created_at, updated_at, group_id, position
end
이 의지 만 색인 항목 = 색인 정의에서 1
그룹 테이블의 열이 비활성화되었습니다. 나는 "groups.disabled = 'f'"와 같은 것을 필요로한다. – Denis
Item.joins (: group) .where (: groups => {: disabled => [nil, false]}),이 항목 만 색인화해야합니다. – Denis