I have the following:
time_range = (1.month.ago.beginning_of_month..1.month.ago.end_of_month)
Comment.where(:created_at => time_range).count
How can I add to the where clause with a statement like:
.where("user_id is not in (?)",[user_ids]).
How can I combine the two? Thanks
Just write it like raw SQL:
Comment.where(
"(user_id > ? AND user_id < ? ) OR (created_at > ? AND created_at < ?)",
100, 200, "2022-06-01", "2022-06-05")
Comment.
where(:created_at => time_range).
where("user_id is not in (?)",[user_ids])
which will produce SQL like : select ... where ... AND ...