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

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -