ruby on rails - How to query multiple columns against a single array of ids -
i have following model:
message.rb: sender_id, receiver_id, created_at
i find messages sender_id , receiver_id both within array of ids [1,4,41,543,312,62,234]. group messages pair (sender_id & receiver_id) ordered created_at.
is right way write query? looking optimal solution here...
message.where("sender_id in ? , receiver_id in ?", @ids)
thanks
try:-
message.where("sender_id in (?) , receiver_id in (?)", @ids, @ids).order("created_at asc")
Comments
Post a Comment