Skip to content

Instantly share code, notes, and snippets.

@lonelydimple
Created February 1, 2012 21:11
Show Gist options
  • Save lonelydimple/1719488 to your computer and use it in GitHub Desktop.
Save lonelydimple/1719488 to your computer and use it in GitHub Desktop.
scope :unread_for_user, lambda { |user|
if user
{
:joins => "left outer join read_receipts rr on messages.id = rr.readable_id and rr.readable_type = 'message' and rr.user_id = #{user.id}",
:conditions => "rr.id is NULL"
}
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment