{"id":26062383,"url":"https://github.com/work-design/rails_audit","last_synced_at":"2025-04-11T11:09:54.152Z","repository":{"id":2185322,"uuid":"42757218","full_name":"work-design/rails_audit","owner":"work-design","description":"记录数据变动，可恢复，可审核","archived":false,"fork":false,"pushed_at":"2025-04-09T03:43:24.000Z","size":326,"stargazers_count":2,"open_issues_count":4,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-09T04:27:30.439Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/work-design.png","metadata":{"funding":{"github":["qinmingyuan"]},"files":{"readme":"README.en.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2015-09-19T03:00:41.000Z","updated_at":"2025-04-09T03:43:27.000Z","dependencies_parsed_at":"2023-07-05T19:17:48.047Z","dependency_job_id":"0a0621d3-7d1c-4d28-9bc4-95ee5c2f2a25","html_url":"https://github.com/work-design/rails_audit","commit_stats":{"total_commits":231,"total_committers":2,"mean_commits":115.5,"dds":"0.0043290043290042934","last_synced_commit":"24095a2ce74a61dc3a7918728b4495f37e35ba66"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/work-design%2Frails_audit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/work-design%2Frails_audit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/work-design%2Frails_audit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/work-design%2Frails_audit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/work-design","download_url":"https://codeload.github.com/work-design/rails_audit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248381789,"owners_count":21094528,"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","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":[],"created_at":"2025-03-08T15:59:44.705Z","updated_at":"2025-04-11T11:09:54.133Z","avatar_url":"https://github.com/work-design.png","language":"Ruby","funding_links":["https://github.com/sponsors/qinmingyuan"],"categories":[],"sub_categories":[],"readme":"# RailsAudit\n\nUnlike [audited](https://github.com/collectiveidea/audited) and [paper_trail](https://github.com/airblade/paper_trail) etc. These model audit tools use model callbacks to record every changes.\n\n`rails_audit` record ActiveRecord Model changes in Controllers, it will record context with model changes:\n\n1. controller\n2. action\n3. request.remote_ip\n4. current_operator\n5. any other info you want to record..\n\n### Model style audit VS controller style audit\n\n| Model Style Audit | Controller style Audit |\n| --- | --- |\n| Record every changes | Record only when you marked |\n| use model callback, can skip by the data persistence not commit callback | No model callback |\n| use thread variables delivery state from controller to model | Just add variables you can get in controller |\n\n## Usage\n\n### in Model\n1. include Audited\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  include RailsAuditExt::Audited\n  \nend\n\n```\n\n### in Controller\n\n```ruby\nclass UsersController \u003c ApplicationController\n  include RailsAudit::Application\n  # use after action, will auto record changes by use saved_changes api\n  after_action only: [:update, :create, :destroy] do\n    mark_audits(:@user, :@role, note: 'note something!', extra: { client_headers: request.headers })\n  end\n  \nend\n```\n\n### in View\n```ruby\n  link_to 'Audits', audits_path('User', user.id)\n```\n\n## 许可证\nLicense 采用 [LGPL License](https://opensource.org/licenses/LGPL-3.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwork-design%2Frails_audit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwork-design%2Frails_audit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwork-design%2Frails_audit/lists"}