Rails 2.3.5 Searchlogic 2.3.27
我有以下型号;
class Outbreak < ActiveRecord::Base
has_many :bacterial_agents, :dependent => :destroy
has_many :bacteria, :through => :bacterial_agents
has_many :viral_agents, :dependent => :destroy
has_many :viruses, :through => :viral_agents
end
class BacterialAgent < ActiveRecord::Base
belongs_to :outbreak
belongs_to :bacterium
end
class Bacterium < ActiveRecord::Base
has_many :bacterial_agents
has_many :outbreaks, :through => :bacterial_agents
end
class ViralAgent < ActiveRecord::Base
belongs_to :outbreak
belongs_to :virus
end
class Virus < ActiveRecord::Base
has_many :viral_agents
has_many :outbreaks, :through => :viral_agents
end
我目前正试图让Searchlogic接受“OR”条件,以便在病毒和细菌模型之间进行搜索;
params[:search] = {"bacterial_agents_bacterium_name_like_any" => "VTEC O157", "viral_agents_virus_name_like_any" => "NOROVIRUS"}
@search = Outbreak.search(params[:search])
作用域“_or_viral_agents_virs_name_like”未被识别,尽管这两个作用域都可以在没有“或”的情况下工作。返回的输出应显示细菌名称类似“VTEC O157”或病毒名称类似“NOROVIRUS”的所有记录(“any”子句允许每个记录有多个名称)。
有什么想法吗?