开发者

RoR: Search Logic, How do I use OR with two different values on the same field?

开发者 https://www.devze.com 2023-03-24 02:22 出处:网络
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开发者_JS百科/08/26/using-searchlogic-to-com

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开发者_JS百科/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) ?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号