{"id":13400345,"url":"https://github.com/public-activity/public_activity","last_synced_at":"2026-01-16T04:57:08.235Z","repository":{"id":37322744,"uuid":"1421024","full_name":"public-activity/public_activity","owner":"public-activity","description":"Easy activity tracking for models - similar to Github's Public Activity","archived":false,"fork":false,"pushed_at":"2025-05-11T01:06:04.000Z","size":632,"stargazers_count":2990,"open_issues_count":20,"forks_count":334,"subscribers_count":55,"default_branch":"main","last_synced_at":"2025-12-11T21:35:28.177Z","etag":null,"topics":["activerecord","activity-stream","hackertoberfest","news-feed","rails","ruby","tracking"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/public-activity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-02-28T10:25:44.000Z","updated_at":"2025-12-04T10:15:18.000Z","dependencies_parsed_at":"2023-02-09T01:45:41.417Z","dependency_job_id":"cf13e536-2145-4969-a1a8-63f237f0da28","html_url":"https://github.com/public-activity/public_activity","commit_stats":{"total_commits":514,"total_committers":47,"mean_commits":"10.936170212765957","dds":0.5369649805447471,"last_synced_commit":"0e422b4e1bfb0da99ee86f5a6eec69a31e14c66d"},"previous_names":["pokonski/public_activity","chaps-io/public_activity"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/public-activity/public_activity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-activity%2Fpublic_activity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-activity%2Fpublic_activity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-activity%2Fpublic_activity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-activity%2Fpublic_activity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/public-activity","download_url":"https://codeload.github.com/public-activity/public_activity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-activity%2Fpublic_activity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27773276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-16T02:00:10.477Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","activity-stream","hackertoberfest","news-feed","rails","ruby","tracking"],"created_at":"2024-07-30T19:00:50.945Z","updated_at":"2025-12-16T23:55:34.123Z","avatar_url":"https://github.com/public-activity.png","language":"Ruby","funding_links":[],"categories":["Ruby","ActiveRecord"],"sub_categories":[],"readme":"# PublicActivity [![Code Climate](https://codeclimate.com/github/chaps-io/public_activity.svg)](https://codeclimate.com/github/chaps-io/public_activity) [![Gem Version](https://badge.fury.io/rb/public_activity.svg)](http://badge.fury.io/rb/public_activity)\n\n`public_activity` provides easy activity tracking for your **ActiveRecord**, **Mongoid 3** and **MongoMapper** models\nin Rails 6.1+. Simply put: it records what has been changed or created and gives you the ability to present those\nrecorded activities to users - similarly to how GitHub does it.\n\n## Table of contents\n\n- [Ruby/Rails version support](#ruby-rails-version-support)\n- [Table of contents](#table-of-contents)\n- [Example](#example)\n  - [Online demo](#online-demo)\n- [Screencast](#screencast)\n- [Setup](#setup)\n  - [Gem installation](#gem-installation)\n  - [Database setup](#database-setup)\n  - [Model configuration](#model-configuration)\n    - [Custom activities](#custom-activities)\n  - [Displaying activities](#displaying-activities)\n    - [Layouts](#layouts)\n    - [Locals](#locals)\n    - [Activity views](#activity-views)\n    - [I18n](#I18n)\n- [Testing](#testing)\n- [Documentation](#documentation)\n- [Common examples](#common-examples)\n- [Help](#help)\n- [License](#license)\n\n## Ruby/Rails version support\n\nVersion `~\u003e 3.0`` supports Ruby 3.0+ and Rails 6.1+. For older Ruby versions\n(≤2.7) and Rails 5.0+ you can use version `~\u003e 2.0` until you can upgrade to\nnewer versions of Ruby + Rails.\n\nIssues related to those unsupported versions of Ruby/Rails will be closed\nwithout resolution and PRs will not be accepted.\n\n## Example\n\nHere is a simple example showing what this gem is about:\n\n![Example usage](http://i.imgur.com/q0TVx.png)\n\n### Demo app\n\nThe source code of the demo is hosted here: https://github.com/pokonski/activity_blog\n\n## Screencast\n\nRyan Bates made a [great screencast](http://railscasts.com/episodes/406-public-activity) describing how to integrate Public Activity in your Rails Application.\n\n## Setup\n\n### Gem installation\n\nYou can install `public_activity` as you would any other gem:\n\n    gem install public_activity\n\nor in your Gemfile:\n\n```ruby\ngem 'public_activity'\n```\n\n### Database setup\n\nBy default _public_activity_ uses Active Record. If you want to use Mongoid or MongoMapper as your backend, create\nan initializer file in your Rails application with the corresponding code inside:\n\nFor _Mongoid:_\n\n```ruby\n# config/initializers/public_activity.rb\nPublicActivity::Config.set do\n  orm :mongoid\nend\n```\n\nFor _MongoMapper:_\n\n```ruby\n# config/initializers/public_activity.rb\nPublicActivity::Config.set do\n  orm :mongo_mapper\nend\n```\n\n**(ActiveRecord only)** Create migration for activities and migrate the database (in your Rails project):\n\n    rails g public_activity:migration\n    rake db:migrate\n\n### Model configuration\n\nInclude `PublicActivity::Model` and add `tracked` to the model you want to keep track of:\n\nFor _ActiveRecord:_\n\n```ruby\nclass Article \u003c ActiveRecord::Base\n  include PublicActivity::Model\n  tracked\nend\n```\n\nFor _Mongoid:_\n\n```ruby\nclass Article\n  include Mongoid::Document\n  include PublicActivity::Model\n  tracked\nend\n```\n\nFor _MongoMapper:_\n\n```ruby\nclass Article\n  include MongoMapper::Document\n  include PublicActivity::Model\n  tracked\nend\n```\n\nAnd now, by default create/update/destroy activities are recorded in activities table.\nThis is all you need to start recording activities for basic CRUD actions.\n\n_Optional_: If you don't need `#tracked` but still want the comfort of `#create_activity`,\nyou can include only the lightweight `Common` module instead of `Model`.\n\n#### Custom activities\n\nYou can trigger custom activities by setting all your required parameters and triggering `create_activity`\non the tracked model, like this:\n\n```ruby\n@article.create_activity key: 'article.commented_on', owner: current_user\n```\n\nSee this entry http://rubydoc.info/gems/public_activity/PublicActivity/Common:create_activity for more details.\n\n### Displaying activities\n\nTo display them you simply query the `PublicActivity::Activity` model:\n\n```ruby\n# notifications_controller.rb\ndef index\n  @activities = PublicActivity::Activity.all\nend\n```\n\nAnd in your views:\n\n```erb\n\u003c%= render_activities(@activities) %\u003e\n```\n\n*Note*: `render_activity` is a helper for use in view templates. `render_activity(activity)` can be written as `activity.render(self)` and it will have the same meaning.\n\n*Note*: `render_activities` is an alias for `render_activity` and does the same.\n\n#### Layouts\n\nYou can also pass options to both `activity#render` and `#render_activity` methods, which are passed deeper\nto the internally used `render_partial` method.\nA useful example would be to render activities wrapped in layout, which shares common elements of an activity,\nlike a timestamp, owner's avatar etc:\n\n```erb\n\u003c%= render_activities(@activities, layout: :activity) %\u003e\n```\n\nThe activity will be wrapped with the `app/views/layouts/_activity.erb` layout, in the above example.\n\n**Important**: please note that layouts for activities are also partials. Hence the `_` prefix.\n\n#### Locals\n\nSometimes, it's desirable to pass additional local variables to partials. It can be done this way:\n\n```erb\n\u003c%= render_activity(@activity, locals: {friends: current_user.friends}) %\u003e\n```\n\n*Note*: Before 1.4.0, one could pass variables directly to the options hash for `#render_activity` and access it from activity parameters. This functionality is retained in 1.4.0 and later, but the `:locals` method is **preferred**, since it prevents bugs from shadowing variables from activity parameters in the database.\n\n#### Activity views\n\n`public_activity` looks for views in `app/views/public_activity`.\n\nFor example, if you have an activity with `:key` set to `\"activity.user.changed_avatar\"`, the gem will look for a partial in `app/views/public_activity/user/_changed_avatar.(erb|haml|slim|something_else)`.\n\n*Hint*: the `\"activity.\"` prefix in `:key` is completely optional and kept for backwards compatibility, you can skip it in new projects.\n\nIf a view file does not exist, then p_a falls back to the old behaviour and tries to translate the activity `:key` using `I18n#translate` method (see the section below).\n\n#### I18n\n\nTranslations are used by the `#text` method, to which you can pass additional options in form of a hash. `#render` method uses translations when view templates have not been provided. You can render pure i18n strings by passing `{display: :i18n}` to `#render_activity` or `#render`.\n\nTranslations should be put in your locale `.yml` files. To render pure strings from I18n Example structure:\n\n```yaml\nactivity:\n  article:\n    create: 'Article has been created'\n    update: 'Someone has edited the article'\n    destroy: 'Some user removed an article!'\n```\n\nThis structure is valid for activities with keys `\"activity.article.create\"` or `\"article.create\"`. As mentioned before, `\"activity.\"` part of the key is optional.\n\n## Testing\n\nFor RSpec you can first disable `public_activity` and add the `test_helper` in `rails_helper.rb` with:\n\n```ruby\n#rails_helper.rb\nrequire 'public_activity/testing'\n\nPublicActivity.enabled = false\n```\n\nIn your specs you can then blockwise decide whether to turn `public_activity` on\nor off.\n\n```ruby\n# file_spec.rb\nPublicActivity.with_tracking do\n  # your test code goes here\nend\n\nPublicActivity.without_tracking do\n  # your test code goes here\nend\n```\n\n## Documentation\n\nFor more documentation go [here](http://rubydoc.info/gems/public_activity/index)\n\n## Common examples\n\n* [[How to] Set the Activity's owner to current_user by default](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Set-the-Activity's-owner-to-current_user-by-default)\n* [[How to] Disable tracking for a class or globally](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Disable-tracking-for-a-class-or-globally)\n* [[How to] Create custom activities](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Create-custom-activities)\n* [[How to] Use custom fields on Activity](https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Use-custom-fields-on-Activity)\n\n## Help\n\nIf you need help with using public_activity please visit our discussion group and ask a question there:\n\nhttps://groups.google.com/forum/?fromgroups#!forum/public-activity\n\nPlease do not ask general questions in the Github Issues.\n\n## License\nCopyright (c) 2011-2013 Piotrek Okoński, released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-activity%2Fpublic_activity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpublic-activity%2Fpublic_activity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-activity%2Fpublic_activity/lists"}