Originally published at: http://www.sitepoint.com/activity-feeds-rails/
Activity feeds are all over the place. For example, Github’s main page lists all of the activity in your social coding network: one of your friends created or cloned a repo, a new issue was opened, your repo was forked or starred, etc.
Twitter displays the latest tweets, retweets, and replies.
That’s a convenient and easy way for users to learn about recent updates. How about trying to replicate the same functionality with Rails? Turns out, there is a convenient gem that makes the development process very easy!
In this article, I am going to talk about public_activity, a gem created by Piotrek Okoński to easily track activity for models (and more, actually). I will show you how to easily create an activity feed and employ various features of public_activity
to extend the app further.
Before proceeding, I wanted to make a small note. Some months ago, I wrote an article Versioning with PaperTrail that covered paper_trail
, a gem used to implement version control of an application’s models. In some ways, paper_trail
is similar to public_activity
and could be used to implement a solution similar to the one presented in this article. However, paper_trail
is aimed at crafting versioning systems, whereas public_activity
was created specifically to implement activity feeds.
The working demo is available at sitepoint-public-activity.herokuapp.com.
The source code is available on GitHub.