public-activity/public_activity
68.8
Adequate · 19 September 2026
1.4k
lines of production code
Ruby
primary language
1
measurement over time
What this system is
PublicActivity is a Ruby gem that provides activity tracking for models across multiple Object-Relational Mappers, including ActiveRecord, Mongoid, and MongoMapper. It enables applications to record and display user actions by linking activities to trackable, owner, and recipient entities through polymorphic associations. The system supports flexible configuration, allowing developers to enable or disable tracking per model and customize activity data, while ensuring thread-safe context handling for rendering in web applications.
How it got here
2011 — PublicActivity 3.0 release and scaffolding
7 changes.
This period focused on rebranding the KeepTrack library to PublicActivity and establishing a modern project structure with updated dependencies for Ruby 3.0 and Rails 6.1+. It introduced a new generator system for creating activity tracking migrations and released version 3.0.2, which added thread-safe configuration and improved controller context handling in templates.
2012–2022 — Multi-ORM support and architectural refactoring
11 changes.
This period focused on expanding the library's compatibility by introducing dedicated ORM adapters for ActiveRecord, Mongoid, and MongoMapper, alongside comprehensive test coverage for these integrations. The codebase underwent significant internal refactoring to improve organization, including the extraction of activity actions into separate modules, the addition of recipient tracking support, and the implementation of per-model deactivation features.
Features
Add Mongoid ORM adapter for activity tracking
Introduces support for Mongoid as an Object-Relational Mapping backend for the PublicActivity gem. This change adds the necessary model definitions (Activity), association modules (Activist for owners/recipients, Trackable for sources), and an adapter layer that enables users to record and query activities using Mongoid documents instead of ActiveRecord models. The Activity model includes polymorphic associations for trackable, owner, and recipient, and conditionally includes dynamic attributes based on the Mongoid version.
_lib/public\activity/orm/mongoid · high confidence
Add initial MongoMapper ORM support
Introduces the first set of files to enable PublicActivity with MongoMapper. This includes the Activity document model with polymorphic associations for trackable, owner, and recipient, an adapter for creating activities, and modules to extend models as activists (for listing activities by owner) and trackables (for listing activities on the model itself).
_lib/public\_activity/orm/mongo\mapper · high confidence
Added ORM adapters for ActiveRecord, MongoMapper, and Mongoid
The library now supports multiple Object-Relational Mappers by introducing specific adapter modules for ActiveRecord, MongoMapper, and Mongoid. These new files in the \lib/public\_activity/orm\ directory act as entry points that load the corresponding activity, adapter, activist, and trackable implementations for each ORM, allowing users to track public activity across these different data persistence layers.
_lib/public\activity/orm · high confidence
Added PublicActivity generator base module
A new generator base module has been added to the library, providing the source root configuration required to locate migration templates for the PublicActivity gem. This change introduces the foundational structure for the generator, enabling the creation of activity tracking tables via the command line.
lib/generators · high confidence
Initial project scaffolding and configuration
The repository is initialized with standard project configuration files, including \.editorconfig\ for consistent code formatting, \.gitignore\ to exclude build artifacts and IDE files, and \.travis.yml\ to define the CI matrix for Ruby and Rails versions. The \Appraisals\ file is added to manage testing across multiple Rails versions (6.1, 7.0, 7.1). Documentation is established with a comprehensive \README.md\ and a \CHANGELOG.md\ tracking versions from 0.5.4 to 3.0.2. Legacy Rails plugin hooks (\init.rb\, \install.rb\, \uninstall.rb\) are removed, and the \Rakefile\ is updated to use YARD for documentation generation instead of RDoc.
(repo-wide) · high confidence
Introduce ActiveRecord ORM support for PublicActivity
This change adds the initial implementation of ActiveRecord support for the PublicActivity gem, enabling activity tracking for Rails applications. It introduces the \PublicActivity::Activity\ model, which defines polymorphic associations for \trackable\, \owner\, and \recipient\, and handles database connection errors gracefully during serialization setup. The \Activist\ module allows models to include \activist\ to expose \activities\_as\_owner\ and \activities\_as\_recipient\ associations, while the \Trackable\ module provides the standard \activities\ association. The \Adapter\ class implements the core logic for creating activities via \create\_activity\ and \create\_activity!\.
_lib/public\_activity/orm/active\record · high confidence
New migration generator for adding recipient support to activities
A new generator (\public\_activity:migration\_upgrade\) is introduced to help users upgrade their existing activity tracking setup. Running this generator creates a migration that alters the \activities\ table by adding a polymorphic \recipient\ association, enabling the system to track who received specific activities.
_lib/generators/public\_activity/migration\upgrade · high confidence
New migration generator for creating activity tracking tables
A new generator class has been added to create database migrations for the public\_activity gem. Users can now run this generator to scaffold a migration file (defaulting to 'create\_activities') that sets up the necessary schema for tracking activities, simplifying the initial setup process.
_lib/generators/public\activity/migration · high confidence
Behavioural changes
New per-class deactivation and refined tracking configuration
The library now includes a new \Deactivatable\ role that allows users to disable PublicActivity on a per-model basis using \public\_activity\_off\ and \public\_activity\_on\ class methods, providing finer control over which models generate activity records. Additionally, the \Tracked\ role has been refactored to support custom fields on all three tiers (global, class, and instance) and ensures that custom fields do not leak between parent and child classes, while also clarifying that ORM-dependent associations are handled within this module.
_lib/public\activity/roles · high confidence
PublicActivity 3.0.2 release with thread-safe configuration and rendering improvements
This release updates the gem to version 3.0.2 and introduces thread-safe configuration storage using thread-local variables, ensuring that settings like ORM, table name, and enabled status are isolated per request thread rather than shared globally. It also enhances the activity rendering logic by passing the controller and current user to view templates via locals, allowing templates to access \current\_user\ and other controller context safely. Additionally, the \render\ method now supports passing \:locals\ to merge with default template variables, and the \text\ method for i18n translations accepts additional runtime parameters.
_lib/public\activity · high confidence
Rebranding to PublicActivity with new module structure
The library has been rebranded from KeepTrack to PublicActivity. The main entry point is now the PublicActivity module, which provides global configuration and toggles (enabled/enabled=) to control activity tracking. The module includes a Model concern for ActiveRecord models that integrates tracking, deactivation, and activist association features. The old keep\_track.rb file has been removed.
lib · high confidence
Refactored activity actions into separate modules with Rails 5.1 compatibility
The activity tracking logic for creation, destruction, and updates has been extracted into dedicated modules (Creation, Destruction, Update) to improve code organization. The update action now supports Rails 5.1+ by using the \saved\_changes?\ method when available, falling back to \changed?\ for older versions, ensuring compatibility across Rails versions.
_lib/public\activity/actions · high confidence
Refactored activity storage and rendering utilities
The library has reorganized its internal structure by introducing dedicated utility modules for controller context management and view rendering. A new \StoreController\ module now explicitly handles storing and retrieving the current controller instance via thread-local storage, ensuring activities have access to the correct context during rendering. Additionally, a \ViewHelpers\ module provides the \render\_activity\ (and aliased \render\_activities\) helper, which allows views to render single activities or collections of activities, including support for lazy-loaded collections that respond to \map\. These changes streamline how activities are stored and displayed without altering the public API surface.
_lib/public\activity/utility · high confidence
Updated migration template to use Rails 6.1 and polymorphic associations
The generated migration template for the activities table has been updated to target Rails 6.1, ensuring compatibility with newer Rails versions. The schema now uses polymorphic associations for the trackable, owner, and recipient columns, allowing activities to be linked to any model type rather than a single specific one. Additionally, the template includes the frozen\_string\_literal pragma for improved Ruby performance and safety.
_lib/generators/public\activity/migration/templates · high confidence
Test coverage
Added comprehensive test suite for PublicActivity; Added test migration files for Rails 6.1 compatibility.
Dependencies
Add support for Rails 7.1 and configure bundle retry
The gemfiles directory now includes dedicated Appraisal gemfiles for Rails 6.1, 7.0, and 7.1, enabling testing against these specific versions. Additionally, a .bundle/config file has been added to enable bundle install retries, improving resilience during dependency resolution.
gemfiles · high confidence
Update gem dependencies and Ruby version requirements
The public\_activity gem now requires Ruby 3.0.0 or higher and has updated its runtime dependencies to support Rails 6.1 and later (actionpack, railties, and activerecord). Development dependencies have been refreshed to include appraisal, minitest, mocha, pry, simplecov, sqlite3 (\~\> 1.4), and yard, while the gemspec now explicitly defines these dependencies rather than relying on a separate Gemfile for resolution.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 69.
Lenses
- Code Health 100
- Architecture 69
- Maturity 61
- Readiness 67
- Security 96
- Domain Modelling 100
Changes since last survey
- 300 commits — 246 feature/other, 54 fixes
By area
- (root) — 125 commits
- lib/public_activity — 85 commits
- (repo) — 42 commits
- .github/workflows — 9 commits
- test/test_helper.rb — 9 commits
- lib/generators — 5 commits
- test/test_common.rb — 5 commits
- test/test_tracking.rb — 4 commits
- gemfiles/Gemfile.rails-3.X — 3 commits
- test/migrations — 3 commits
- lib/public_activity.rb — 2 commits
- gemfiles/.bundle — 1 commit
- test/mongo_mapper.yml — 1 commit
- test/mongoid.yml — 1 commit
- test/test_activist.rb — 1 commit
- test/test_activity.rb — 1 commit
- test/test_generators.rb — 1 commit
- test/test_testing.rb — 1 commit
- test/views — 1 commit
Notable commits
- fix: - Fix missing attr_accessible for AR < 4.0 - Update run_tests.sh to include different versions of ActiveRecord - remove UPGRADING file in .gemspec - Include proper test/ directory, not spec/
- fix: Add specs and fix error when no :layout supplied to #render_activity
- fix: Backport fix from master to minitest version in new Rubies.
- fix: Fix #335
- fix: Fix Markdown syntax
- fix: Fix Ruby 2.7 warnings
- fix: Fix YAML loading for newer Psych versions
- fix: Fix badges
- fix: Fix docs for activities_at_*
- fix: Fix failing tests due to global controller setup
- fix: Fix flaky tests
- fix: Fix incorrect Ruby version
- fix: Fix issue introduced in ec2cbdb while running db:schema:load
- fix: Fix linter issue and refactor
- fix: Fix linter issues
- fix: Fix migrators not adding an extension in Rails 4.0.
- fix: Fix minitest deprecation warnings and improve and unify code style
- fix: Fix minitest version in Rails-specific Gemfiles.
- fix: Fix missing mocks
- fix: Fix missing require
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
public-activity/public_activity was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 1f3a5568adcb55317552b7528cc489b8ccbbb306 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.