2

How do I create an ActiveRecord query without using a SQL string in Rails to get something like:

books = Book.where(author: 1, **from_day: [1,5] or to_day: [1,5]**)
potashin
  • 44,205
  • 11
  • 83
  • 107
Nadiya
  • 1,421
  • 4
  • 19
  • 34

1 Answers1

0

You can try this:

books = Book.where(author: 1).where("from_day IN (?) or to_day IN (?)", [1,5],[1,5])
Andrei
  • 42,814
  • 35
  • 154
  • 218
dp7
  • 6,651
  • 1
  • 18
  • 37