How to enable users activity tracking using the public_activity gem?
On Rails, the public_activity provides easy way for tracking activity for ActiveRecord, Mongoid 3 and MongoMapper models. Simply we have to put records what has been changed or created and that will gives the ability to present those recorded activities to users. Following Github screenshot showing the expected output from the Rails users activity tracking-
Following steps we have to follow: (ActiveRecord only)
gem 'public_activity' on your Gemfile
rails g public_activity:migration
Now let’s configure the Model
class Post < ActiveRecord::Base
@post.create_activity key: 'post.commented_on', owner: current_user
@activities = PublicActivity::Activity.all
That’s all for tracking all activities.
Happy coding 🙂