Closed leadingproperties closed 7 years ago
What about this:
class Conversation < ApplicationRecord
has_many :messages
acts_as_readable_on on: :updated_at
end
class Message < ApplicationRecord
belongs_to :conversation, touch: true
acts_as_readable :on => :created_at
end
Conversion.unread_by(user)
Thank's for quick response. You are opened my eyes with this simple solution. I review my design and notice that I don't need mark read messages at all. I can mark Conversations. Thanks!
I have Conversation that has_many Messages. Is there best way to get Conversations with unread messages inside?
After few hours of try's, and after I wrote this question (order thoughts) - my solution is:
Think this query will return Conversations with unread messages inside. May be there is the better way?