我使用 gem "thinking_sphinx", version => '1.4.14' 进行了搜索。
我正在尝试在我的表策略中创建条件 policy.deleted= 0
这是我的控制器
class PolicyController < ApplicationController
def search
@policies = Policy.search params[:search],:conditions=>[policies.deleted=0] :include => :client, :match_mode => :boolean
end
end
我的模型是:“政策”和“客户”
class Policy < ActiveRecord::Base
belongs_to :client
define_index 'policy_foo' do
indexes mum_policy
indexes [client.name, client.lastname1], :as => :client_name
has client_id, created_at
end
end
class Client < ActiveRecord::Base
has_many :policies
end
我试过了
def search
@policies = Policy.search params[:query],:include => :client, :match_mode => :boolean
@search = Policy.find(:all,:conditions=>['deleted=0 and client_id IN (?)',@client])
end
有人知道如何搜索和条件删除= 0?
我将非常感谢帮助