RoR:搜索逻辑,如何在同一字段上使用 OR 与两个不同的值?

发布于 2024-11-27 16:52:06 字数 407 浏览 3 评论 0 原文

我想做类似的事情: @search(some_condition 或 some_other_condition)

这就是互联网所说的使用 OR http://www.binarylogic.com/2009/08/26/using-searchlogic-to-combine-named-scopes-with-or/

不幸的是,它只使用相同的值两个字段。

那么..有没有办法做到 @search.(some_field == value OR other_field == other_value) ?

I want to do something similar to :
@search(some_condition or some_other_condition)

this is how the internet says to use OR http://www.binarylogic.com/2009/08/26/using-searchlogic-to-combine-named-scopes-with-or/

unfortunately it only uses the same value for two fields.

So.. IS there a way to do @search.(some_field == value OR other_field == other_value) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由范儿 2024-12-04 16:52:06

不要求助于 searchlogic 的 或 部分,只需使用 ruby​​。

result = @search.first_name_like('The') || @search.last_name_like('LindyHop')

我是否有理由不明白你为什么不能这样做?

Don't resort to searchlogic for the or part, just use ruby.

result = @search.first_name_like('The') || @search.last_name_like('LindyHop')

Is there a reason that I'm not following as to why you can't do it like this?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文