I'm trying to implement a simple Inbox system for users of my app so that can send basic messages to each other - just like in many forum systems.
User has_many :messages, how do I keep track of and notify the User of messages unread since last time they were read?
I'm thinking clicks on the link to the
Messages screen need to be recorded in a separate table (
Is that the best approach here?
So then I check the
MessagesClicks table to see if any new messages have arrived since the last time that link was clicked - based on a
I would keep track of when a message was read on the message itself with the default value of null.
If the user has any Messages with a dateRead value of null then they have unread messages.
When you display a message to the user on the Messages screen, update the dateRead property of the message from null to now.