I am currently using the gem 'Public Activity', and in the view I have a users activity filtered to only show that user the activities that apply to them, such as 'John Smith commented on your post'. However, I would like to add notifications to this, like facebook or twitter, where a badge shows a number, and when you see the feed the badge disappears.
I have found a gem called Unread which looks ideal, except it requires adding acts_as_readable :on => :created_at
to your model, and as I'm using the public_activity gem the class is not accessible to add this.
Is it possible to inject the code the unread gem requires, into the PublicActivity:Activity class?
Links:
gem public_activity: https://github.com/pokonski/public_activity
gem unread: https://github.com/ledermann/unread
To anyone that may find this in future, i implemented a completely different system by data modelling my own notifications. Rather than using public activity and unread, I made a new model called notifications. This had the columns:
Then, whenever I had a user comment or like etc, I built a new notification in the controller, passing in the following information:
In the navigation bar I simply added a badge that counted the current_users unread notifications, based on an application controller variable.
Then, in the notifications controller I had it run a
mark_as_read
action on the view. This then set the notification count back to 0.