Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AREL is super good!
# t = Message.arel_table
# Message.
# joins(:thread).
# where(
# t[:id].eq(
# t.grouping(
# Arel.sql(
# Message.
# select(t[:id]).
# with_deleted.
# where(sender_id: user_id).
# without_anonymous_users.
# with_thread.
# my_messages.
# joins(:thread).
# group(:thread_id).
# order('messages_threads.last_message_at DESC').
# limit(1).
# to_sql
# )
# )
# )
# ).
# order('messages_threads.last_message_at DESC').
# map(&:thread)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.