How would you create a notification system like on SO or Facebook in RoR?

Posted by Justin Meltzer on Stack Overflow See other posts from Stack Overflow or by Justin Meltzer
Published on 2011-04-11T04:00:55Z Indexed on 2012/11/15 11:03 UTC
Read the original article Hit count: 208

I'm thinking that notifications would be it's own resource and have a has_many, through relationship with the user model with a join table representing the associations.

A user having many notifications is obvious, and then a notification would have many users because there would be a number of standardized notifications (a commenting notification, a following notification etc.) that would be associated with many users.

Beyond this setup, I'm unsure how to trigger the creation of notifications based on certain events in your application. I'm also a little unsure of how I'd need to set up routing - would it be it's own separate resource or nested in the user resource? I'd find it very helpful if someone could expand on this.

Lastly, ajax polling would likely improve such a feature.

There's probably some things I'm missing, so please fill this out so that it is a good general resource.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby