rubyrubygemsevent-based-programming

Need recommendations to create an event-based messaging and badging system in Rails


I want to create an event-based notification and badging system that would award users when they accomplish certain goals. Goals might include:

Would this be a job for a state machine such as AASM? I haven't played much with such systems. Would that be the way to go to define events or are there better plugins/solutions that would accommodate this type of behavior? Any tutorials or recommendations for approach would be greatly appreciated.


Solution

  • It seems that the tricky part here is figuring out how you want to maintain the state needed to determine when a badge should be awarded. The state machine plugins for rails aren't going to help you much with that.

    For example, how would a piece of code determine if a user has logged in 10 days straight? Once you figure this out then you can worry about how to organize the event handling.

    Do you need to notify them in real time when they get a badge? If so they then you can easily do this with ActiveRecord::Observer but it may have some latency issues in thelong run (http://api.rubyonrails.org/classes/ActiveRecord/Observer.html)

    If you don't need to do it in real time then you can do it with background jobs of some form. There are a lot of libraries for background jobs out there. I use workling when I don't care about scaling and just want to get something up fast.