我试图使用Searchkick运行搜索并返回基于多个模型.
我的书模型包含了这个
class Book < ActiveRecord::Base
searchkick
has_many :book_subjects
has_many :subjects, through: :book_subjects
belongs_to :author
belongs_to :publisher
end
Run Code Online (Sandbox Code Playgroud)
然后我的控制器有这个
def index
if params[:search].present?
@books = Book.search(params[:search], operator: "or")
else
@books = Book.all
end
end
Run Code Online (Sandbox Code Playgroud)
我希望搜索结果能够搜索相关模型并返回任何结果 - 所以boo主题名称,作者和发布者.
谢谢