This is a common pattern among apps and I am sure has a graceful solution, but for the life of me I can't find an answer. A big issue is I don't quite know what to call it!
I am trying to find the proper solution to give one-time notifications to every user of a system. When that user acknowledges or closes the notification, they do not see it again personally, but others users will until they acknowledge it.
This is common when doing maintenance notices, new features, on-boarding, etc.
Obviously, this would need to live in some database as a flag that this particular has acknowledged this particular message, but it seems like that could become heavy and unwieldy quickly without a well-thought out plan for delivering these.
See my answer to a similar question.
Messages live in my user model as a serialized array. This way I can use simple array methods such as #push
for new messages. Users only deal with messages specific to them, using #delete_at
to cancel individual messages, or #clear
to cancel them all.
For broadcast notifications, you could do something as obnoxious as:
User.all.map {|x| x.messages.push "You have been notified." ; x.save }
which, if used infrequently, isn't that big of a deal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With