If I understand your code correctly, you should be able to do that with
published.where(:message_users => { :sender => false, :trash => false , :deleted => false, :read_at => nil })
Question
I currently have this scope:
class User
has_many :inbox_messages, :through => :message_users do
def unread
published.where(:message_users => { :sender => false, :trash => false , :deleted => false}).where(MessageUser.arel_table[:read_at].not_eq(nil))
end
end
end
And it's working. But I was wondering if there is way to merge the second where
into the first one.
Solution
If I understand your code correctly, you should be able to do that with
published.where(:message_users => { :sender => false, :trash => false , :deleted => false, :read_at => nil })