Ask A Question


You’re not receiving notifications from this thread.

Could you do a screencast on how to build notifications with Rails?

Ken Hibino asked in General

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

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!


Thank you Chris! Definitely looking forward to the screencast :)


:+1: 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 show actions.




Thank you so much Chris!! your the man!!



Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 81,149+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.