Replies: 1 comment 1 reply
-
If you wanted to keep chaining, you can use DB[:table_name]
.where(...)
.yield_self { |ds| types ? ds.where(type: types) : ds }
.order(...)
.limit(...) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hello, i'm wondering if there might be a simpler way to have a conditional
.where
in a chained query. i have the following which works as expected, other than the unnecessary1=1
being generated:if i use
.where(if X then X else nil end)
, this generatesAND NULL
into the query. is there another possibility i may have missed?Beta Was this translation helpful? Give feedback.
All reactions