0
我的模型是多模式搜索轨
class Product < ActiveRecord::Base
has_many :category_products
has_many :categories , through: :category_products
has_many :product_tags
has_many :tags, through: :product_tags
我想搜索所有三种型号分类,标签,Products.It工作正常,但问题,我面对的是,当我搜索的分类和标签我想得到那里的相关产品。但是,如何区分何时搜索产品列和何时关联表。
我的代码是
@search = Sunspot.search[Product,Category,Tag] do
fulltext params[:search]
paginate(:page => params[:page] || 1, :per_page => 3)
end
@products = @search.results
在我想要得到的产品到底。
It works .... :) –