Da du bruger Rails 5, kan du drage fordel af dets or
metode:
Message.where(to: current_user.id).or(
Message.where(user_id: current_user.id)
).order(connection: :desc, created_at: :desc)
.select('distinct on (connection) *')
Da du bruger Rails 5, kan du drage fordel af dets or
metode:
Message.where(to: current_user.id).or(
Message.where(user_id: current_user.id)
).order(connection: :desc, created_at: :desc)
.select('distinct on (connection) *')