本文介绍了Searchlogic OR条件导致未定义的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定我正在忽略某些东西,因为这是我第一次使用Searchlogic.

I'm sure that I'm overlooking something since this is my first time using Searchlogic.

每当我在控制器中使用类似Listing.city_like_or_state_like(params[:search])的语句时,Rails都会返回未定义方法"错误.我正在尝试搜索同一模型中的2个字段.

Whenever I use a statement like Listing.city_like_or_state_like(params[:search]) in my controller, Rails returns an "Undefined Method" error. I'm trying to search 2 fields within the same model.

但是,如果我使用Listing.city_like(params[:search]),一切都很好.

However, if I use Listing.city_like(params[:search]) everything is totally fine.

我在这里错过了什么吗?我认为OR条件可以与Searchlogic链接在一起.如何实现OR语句?

Am I missing something here? I thought OR conditions could be chained together with Searchlogic. How can I implement an OR statement?

推荐答案

Searchlogic每次调用仅支持一个运算符".所以你想做的是

Searchlogic only supports one "operator" per call. So what you want to do is

Listing.city_or_state_like(params[:search])

这篇关于Searchlogic OR条件导致未定义的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 11:15