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

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -