ActiveRecord query, order by association, last of has_many
问题 Im trying to list all Users by the created_at column of the most recently created associated recored (communications). What I have so far: User.includes(:communications).order( 'communications.created_at IS NULL, communications.created_at asc' ) As it is, desc works as I expect. The issue is when the order is reversed and I try order asc . It appears that is's because the user can have many communications , The query returns the list of users in order of the first communications created