I've been trying to add a notification system (bell icon on the header) to the app I'm building. The implementation I came up with is very awkward and I'm sure there's a better way to do it (maybe using a background job?). Could you do a quick screencast on how to build a notification system with Rails? I'd like to see how you would go about building one!
Yes! Definitely an awesome topic to cover. Quick outline of what it would look like:
class Notification < ActiveRecord::Base belongs_to :user def mark_as_read update(read_at: Time.zone.now) end end
You can look up the unread notifications for the nav, and send over an AJAX request to the Rails app to mark all those as read.
Hopefully able to do a screencast on this soon!
on the notifications system.
Would also be interested in seeing how it'd tie into for example emailing a user the notification as well as adding it to their feed. Would you want to make it so that if you click the link to a forum post in the email it'd mark that notification as read? How could this be done efficiently?
Yeah, you could probably do a special route to the notification. It would mark as read and then redirect you to the actual item in the notification. Either that, or you could mark any notifications for the object loaded in the
Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.