{"id":14955328,"url":"https://github.com/yujideveloper/operator_recordable","last_synced_at":"2025-11-17T03:09:34.156Z","repository":{"id":32985863,"uuid":"144226729","full_name":"yujideveloper/operator_recordable","owner":"yujideveloper","description":" A Rails plugin to set created_by, updated_by, deleted_by to ActiveRecord objects.","archived":false,"fork":false,"pushed_at":"2022-08-27T11:30:28.000Z","size":121,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T17:58:31.512Z","etag":null,"topics":["activerecord","rails","rails5","rails6","rails7","ruby","ruby-gem","ruby-on-rails"],"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/yujideveloper.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-10T02:31:07.000Z","updated_at":"2024-12-17T07:49:25.000Z","dependencies_parsed_at":"2022-09-15T08:31:56.128Z","dependency_job_id":null,"html_url":"https://github.com/yujideveloper/operator_recordable","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/yujideveloper/operator_recordable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujideveloper%2Foperator_recordable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujideveloper%2Foperator_recordable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujideveloper%2Foperator_recordable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujideveloper%2Foperator_recordable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yujideveloper","download_url":"https://codeload.github.com/yujideveloper/operator_recordable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujideveloper%2Foperator_recordable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284813607,"owners_count":27067323,"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-11-17T02:00:06.431Z","response_time":55,"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","rails","rails5","rails6","rails7","ruby","ruby-gem","ruby-on-rails"],"created_at":"2024-09-24T13:10:59.680Z","updated_at":"2025-11-17T03:09:34.138Z","avatar_url":"https://github.com/yujideveloper.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OperatorRecordable\n\n[![Gem Version](https://badge.fury.io/rb/operator_recordable.svg)](https://badge.fury.io/rb/operator_recordable)\n[![Build](https://github.com/yujideveloper/operator_recordable/workflows/Build/badge.svg)](https://github.com/yujideveloper/operator_recordable/actions?query=workflow%3ABuild)\n[![Maintainability](https://api.codeclimate.com/v1/badges/aaa0fcd567da9232a847/maintainability)](https://codeclimate.com/github/yujideveloper/operator_recordable/maintainability)\n\nOperatorRecordable is a Rails plugin gem that makes your ActiveRecord models to be saved or logically deleted with automatically set `created_by`, `updated_by`, and `deleted_by`.\nAlso it makes `creator`, `updater`, and `deleter` `belongs_to` association if a class has `created_by`, `updated_by`, or `deleted_by`.\n\nIt also supports `discarded_by` column if [discard gem](https://github.com/jhawthorn/discard) is available.\n\nThis gem is inspired by [RecordWithOperator](https://github.com/nay/record_with_operator).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'operator_recordable'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install operator_recordable\n\n## Usage\n\n### Configuration\n\n#### Initialize `OperatorRecordable`\n\n``` ruby\n# config/initializers/operator_recordable.rb\nOperatorRecordable.config = {\n  operator_class_name: \"Operator\",\n  creator_column_name: \"created_by\",\n  updater_column_name: \"updated_by\",\n  deleter_column_name: \"deleted_by\",\n  discarder_column_name: \"discarded_by\",\n  creator_association_name: \"creator\",\n  updater_association_name: \"updater\",\n  deleter_association_name: \"deleter\",\n  discarder_association_name: \"discarder\",\n  operator_association_options: {},\n  operator_association_scope: nil,\n  store: :current_attributes_store\n}\n```\n\n##### Options\n\n| Name | Type | Description | Default |\n|:-----|:-----|:------------|:--------|\n| `operator_class_name` | String | class name of your operator model. | `\"Operator\"` |\n| `creator_column_name` | String | column name of creator. | `\"created_by\"` |\n| `updater_column_name` | String | column name of updater. | `\"updated_by\"` |\n| `deleter_column_name` | String | column name of deleter. | `\"deleted_by\"` |\n| `discarder_column_name` | String | column name of discarder. | `\"discarded_by\"` |\n| `creator_association_name` | String | association name of creator. | `\"creator\"` |\n| `updater_association_name` | String | association name of updater. | `\"updater\"` |\n| `deleter_association_name` | String | association name of deleter. | `\"deleter\"` |\n| `discarder_association_name` | String | association name of discarder. | `\"discarder\"` |\n| `operator_association_options` | Hash | options of operator associations. e.g. `{ touch: true }` | `{}` |\n| `operator_association_scope` | Proc | The scope of operator associations. e.g. `-\u003e { with_deleted }`  | `nil` |\n| `store` | Enum | operator store. any value of `:current_attributes_store` or `:request_store` | `:current_attributes_store` |\n\n#### Include `OperatorRecordable` in your model\n\n``` ruby\nclass ApplicationRecord \u003c ActiveRecord::Base\n  self.abstract_class = true\n\n  include OperatorRecordable::Extension\nend\n```\n\n#### Activate `OperatorRecordable` in your model\n\nYou can specify which action you want to save operator like this.\n``` ruby\nclass Post \u003c ApplicationRecord\n  record_operator_on :create, :update, :destroy\nend\n```\n\nOperatorRecordable needs to know who is currently operating. For that, you need to set operator through a following way in a `before_action` callback, etc.\n``` ruby\nOperatorRecordable.operator = current_operator\n```\n\n### Stores\n\n#### `:current_attributes_store`\n\nThis store is implemented by using [`ActiveSupport::CurrentAttributes`](https://api.rubyonrails.org/v5.2.0/classes/ActiveSupport/CurrentAttributes.html).  \nThis is the default store.\n\n#### `:request_store`\n\nThis store is implemented by using [RequestStore gem](https://github.com/steveklabnik/request_store).  \nSo, this requires RequestStore gem.\n\nRequestStore must be loaded before OperatorRecordable.\n\n``` ruby\ngem \"request_store\"\ngem \"operator_recordable\"\n```\nOr\n\n``` ruby\nrequire \"request_store\"\nrequire \"operator_recordable\"\n```\n\nOtherwise, you need to load it yourself.\n``` ruby\nrequire \"operator_recordable/store/request_store\"\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/yujideveloper/operator_recordable.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyujideveloper%2Foperator_recordable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyujideveloper%2Foperator_recordable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyujideveloper%2Foperator_recordable/lists"}