Reputation: 20912
I'm trying to join two different conditions on an Active Record Database.
Usually, I'll join them using a comma (,
) or AND
, but in this case, putting a comma or AND between conditions returns an error.
I wonder how to join those conditions together in one statement (I'm using rails 4):
MyTable.where("created_at < ?", Time.now - 86400) # 86400 represent a day
MyTable.where(my_column: my_variable)
Upvotes: 0
Views: 706
Reputation: 29369
MyTable.where("created_at < ? AND my_column = ?", Time.now - 86400, my_variable)
Upvotes: 1