【发布时间】:2014-04-01 07:32:58
【问题描述】:
在我的应用程序中,我使用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 搜索(当这个参数出现时),我该如何解决这个问题?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 thinking-sphinx has-scope