Aangezien u Rails 5 gebruikt, kunt u profiteren van de or
methode:
Message.where(to: current_user.id).or(
Message.where(user_id: current_user.id)
).order(connection: :desc, created_at: :desc)
.select('distinct on (connection) *')
Aangezien u Rails 5 gebruikt, kunt u profiteren van de or
methode:
Message.where(to: current_user.id).or(
Message.where(user_id: current_user.id)
).order(connection: :desc, created_at: :desc)
.select('distinct on (connection) *')