sqlruby-on-railsrubysqueel

Rails, squeel - loop inside 'where'


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.


Solution

  • Product.where('id >= ? AND id <= ?',array[0],array[1])