Reputation: 5879
I read on the official Rails Documentation how to make a joint query for a model Client
which is associated to many orders
. The code is the following
Client.joins(:orders).where(orders: {created_at: time_range})
and of course it works fine.
I'd like to modify the above inserting a LIKE query, something like
Client.joins(:orders).where(orders: {created_at: time_range, title: "LIKE Meeting"})
What is the right syntax to do that?
Upvotes: 0
Views: 49
Reputation: 5879
Got it!
Client.joins(:orders).where("orders.created_at=? AND orders.title LIKE ? ", time_range, "Meeting")
Upvotes: 1