Ask A Question

Notifications

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!
Thanks!!

Reply

+1

Reply

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!

Reply

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

Reply

:+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?

Reply

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.

Reply

+1.

Reply
Reply

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

Reply

:D

Reply
Join the discussion
Create an account Log in

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

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

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