Question

I want to use some sort of loop or iterator inside where statement like

Product.where{ array.each do |e|
  (id >= e[0]) & (id <= e[1])
end }

Is something like this possible?

In reality query is much more complicated, and I don't want to post whole architecture here.

Was it helpful?

Solution

Product.where('id >= ? AND id <= ?',array[0],array[1])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top