在我的应用程序中,我使用has_scope
gem 和thinking sphinx
,在模型中我写了如下内容:
scope :by_description, -> description { where("description like ?", "%#{description}%") if description.present?}
然后,在控制器中:
has_scope :by_description
def somemimimi
@cars = apply_scopes(Car).order(created_at: :desc).page(params[:page]).per(20)
end
但是当我尝试写类似的东西时:
scope :by_description, -> description { search description}
我收到以下错误
you cannot search with Sphinx through ActiveRecord scopes
但我也只是用 sphinx 搜索(当这个参数出现时),我该如何解决这个问题?