0.0
The project is in a healthy, maintained state
Acts As Active is a tracker and activity generator for any ActiveRecord model, making it easy to generate statistics, streaks, and data visualization.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 2.1

Runtime

 Project Readme

ActsAsActive

Acts As Active adds plug-and-play activity tracking to any ActiveRecord model, giving you instant daily stats, streak analytics, and heatmap-ready data.

It works by automatically establishing a polymorphic association with your model and generating an Activity record for each specified lifecycle event.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add acts_as_active

If bundler is not being used to manage dependencies, install the gem by executing:

gem install acts_as_active

Usage

class Record < ApplicationRecord
  acts_as_active on: [:create, :update],          # ➜ track different actions
                 if:     -> { track_activity? },  # ➜ on different conditions
                 unless: -> { skip_tracking? }
end
record = Record.create!(title: "First draft")   # ➜ records activity for today
record.update!(title: "Second draft")           # ➜ activity count for today = 2
 

record.active_today?                # => true
record.active_on?(Date.yesterday)   # => false
record.activity_count(range: 1.day.ago..Date.today)
# => 2   (two events in the last 24 h)


record.heatmap(range: 1.week.ago..Date.today)
# => { "2025-08-01" => 1, "2025-08-02" => 3, "2025-08-03" => 2 }

record.longest_streak   # => 3   (e.g. active 1-3 Aug)
record.current_streak   # => 2   (e.g. active 5-6 Aug, still “on a streak” today)

Run Tests

ruby -Ilib:ruby test/test_acts_as_active.rb

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/amitleshed/acts_as_active. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the ActsAsActive project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.