[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7840":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},7840,"audited","collectiveidea\u002Faudited","collectiveidea","Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.","",null,"Ruby",3493,662,34,180,0,4,30.46,"MIT License",false,"main",[23,24,25,26,27,28,29],"activerecord","audit","audit-log","audit-trail","auditing","rails","ruby","2026-06-12 02:01:45","Audited\n[![Gem Version](https:\u002F\u002Fimg.shields.io\u002Fgem\u002Fv\u002Faudited.svg)](http:\u002F\u002Frubygems.org\u002Fgems\u002Faudited)\n![Build Status](https:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Faudited\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)\n[![Code Climate](https:\u002F\u002Fcodeclimate.com\u002Fgithub\u002Fcollectiveidea\u002Faudited.svg)](https:\u002F\u002Fcodeclimate.com\u002Fgithub\u002Fcollectiveidea\u002Faudited)\n[![Ruby Style Guide](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fcode_style-standard-brightgreen.svg)](https:\u002F\u002Fgithub.com\u002Ftestdouble\u002Fstandard)\n=======\n\n**Audited** (previously acts_as_audited) is an ORM extension that logs all changes to your models. Audited can also record who made those changes, save comments and associate models related to the changes.\n\n\nAudited currently (5.6) works with Rails 7.2, 7.1, 7.0, 6.1, 6.0, 5.2.\n\nFor Rails 5.0 & 5.1, use gem version 5.4.3\nFor Rails 4, use gem version 4.x\nFor Rails 3, use gem version 3.0 or see the [3.0-stable branch](https:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Faudited\u002Ftree\u002F3.0-stable).\n\n## Supported Rubies\n\nAudited supports and is [tested against](https:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Faudited\u002Factions\u002Fworkflows\u002Fci.yml) the following Ruby versions:\n\n* 2.3 (only tested on Sqlite due to testing issues with other DBs)\n* 2.4\n* 2.5\n* 2.6\n* 2.7\n* 3.0\n* 3.1\n* 3.2\n* 3.3\n\nAudited may work just fine with a Ruby version not listed above, but we can't guarantee that it will. If you'd like to maintain a Ruby that isn't listed, please let us know with a [pull request](https:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Faudited\u002Fpulls).\n\n## Supported ORMs\n\nAudited is currently ActiveRecord-only. In a previous life, Audited worked with MongoMapper. Use the [4.2-stable branch](https:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Faudited\u002Ftree\u002F4.2-stable) if you need MongoMapper.\n\n## Installation\n\nAdd the gem to your Gemfile:\n\n```ruby\ngem \"audited\"\n```\n\nAnd if you're using ```require: false``` you must add initializers like this:\n\n```ruby\n#.\u002Fconfig\u002Finitializers\u002Faudited.rb\nrequire \"audited\"\n\nAudited::Railtie.initializers.each(&:run)\n```\n\nThen, from your Rails app directory, create the `audits` table:\n\n```bash\n$ rails generate audited:install\n$ rake db:migrate\n```\n\nBy default changes are stored in YAML format. If you're using PostgreSQL, then you can use `rails generate audited:install --audited-changes-column-type jsonb` (or `json` for MySQL 5.7+ and Rails 5+) to store audit changes natively with database JSON column types.\n\nIf you're using something other than integer primary keys (e.g. UUID) for your User model, then you can use `rails generate audited:install --audited-user-id-column-type uuid` to customize the `audits` table `user_id` column type.\n\n#### Upgrading\n\nIf you're already using Audited (or acts_as_audited), your `audits` table may require additional columns. After every upgrade, please run:\n\n```bash\n$ rails generate audited:upgrade\n$ rake db:migrate\n```\n\nUpgrading will only make changes if changes are needed.\n\n\n## Usage\n\nSimply call `audited` on your models:\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  audited\nend\n```\n\nBy default, whenever a user is created, updated or destroyed, a new audit is created.\n\n```ruby\nuser = User.create!(name: \"Steve\")\nuser.audits.count # => 1\nuser.update!(name: \"Ryan\")\nuser.audits.count # => 2\nuser.destroy\nuser.audits.count # => 3\n```\n\nAudits contain information regarding what action was taken on the model and what changes were made.\n\n```ruby\nuser.update!(name: \"Ryan\")\naudit = user.audits.last\naudit.action # => \"update\"\naudit.audited_changes # => {\"name\"=>[\"Steve\", \"Ryan\"]}\n```\n\nYou can get previous versions of a record by index or date, or list all\nrevisions.\n\n```ruby\nuser.revisions\nuser.revision(1)\nuser.revision_at(Date.parse(\"2016-01-01\"))\n```\n\n### Specifying columns\n\nBy default, a new audit is created for any attribute changes. You can, however, limit the columns to be considered.\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  # All fields\n  # audited\n\n  # Single field\n  # audited only: :name\n\n  # Multiple fields\n  # audited only: [:name, :address]\n\n  # All except certain fields\n  # audited except: :password\nend\n```\n\n### Specifying callbacks\n\nBy default, a new audit is created for any Create, Update, Touch (Rails 6+) or Destroy action. You can, however, limit the actions audited.\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  # All fields and actions\n  # audited\n\n  # Single field, only audit Update and Destroy (not Create or Touch)\n  # audited only: :name, on: [:update, :destroy]\nend\n```\n\nYou can ignore the default callbacks globally unless the callback action is specified in your model using the `:on` option. To configure default callback exclusion, put the following in an initializer file (`config\u002Finitializers\u002Faudited.rb`):\n\n```ruby\nAudited.ignored_default_callbacks = [:create, :update] # ignore callbacks create and update\n```\n\n### Comments\n\nYou can attach comments to each audit using an `audit_comment` attribute on your model.\n\n```ruby\nuser.update!(name: \"Ryan\", audit_comment: \"Changing name, just because\")\nuser.audits.last.comment # => \"Changing name, just because\"\n```\n\nYou can optionally add the `:comment_required` option to your `audited` call to require comments for all audits.\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  audited :comment_required => true\nend\n```\n\nYou can update an audit only if audit_comment is present. You can optionally add the `:update_with_comment_only` option set to `false` to your `audited` call to turn this behavior off for all audits.\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  audited :update_with_comment_only => false\nend\n```\n\n### Limiting stored audits\n\nYou can limit the number of audits stored for your model. To configure limiting for all audited models, put the following in an initializer file (`config\u002Finitializers\u002Faudited.rb`):\n\n```ruby\nAudited.max_audits = 10 # keep only 10 latest audits\n```\n\nor customize per model:\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  audited max_audits: 2\nend\n```\n\nWhenever an object is updated or destroyed, extra audits are combined with newer ones and the old ones are destroyed.\n\n```ruby\nuser = User.create!(name: \"Steve\")\nuser.audits.count # => 1\nuser.update!(name: \"Ryan\")\nuser.audits.count # => 2\nuser.destroy\nuser.audits.count # => 2\n```\n\n### Current User Tracking\n\nIf you're using Audited in a Rails application, all audited changes made within a request will automatically be attributed to the current user. By default, Audited uses the `current_user` method in your controller.\n\n```ruby\nclass PostsController \u003C ApplicationController\n  def create\n    current_user # => #\u003CUser name: \"Steve\">\n    @post = Post.create(params[:post])\n    @post.audits.last.user # => #\u003CUser name: \"Steve\">\n  end\nend\n```\n\nTo use a method other than `current_user`, put the following in an initializer file (`config\u002Finitializers\u002Faudited.rb`):\n\n```ruby\nAudited.current_user_method = :authenticated_user\n```\n\nOutside of a request, Audited can still record the user with the `as_user` method:\n\n```ruby\nAudited.audit_class.as_user(User.find(1)) do\n  post.update!(title: \"Hello, world!\")\nend\npost.audits.last.user # => #\u003CUser id: 1>\n```\n\nThe standard Audited install assumes your User model has an integer primary key type. If this isn't true (e.g. you're using UUID primary keys), you'll need to create a migration to update the `audits` table `user_id` column type. (See Installation above for generator flags if you'd like to regenerate the install migration.)\n\n#### Custom Audit User\n\nYou might need to use a custom auditor from time to time. This can be done by simply passing in a string:\n\n```ruby\nclass ApplicationController \u003C ActionController::Base\n  def authenticated_user\n    if current_user\n      current_user\n    else\n      'Alexander Fleming'\n    end\n  end\nend\n```\n\n`as_user` also accepts a string, which can be useful for auditing updates made in a CLI environment:\n\n```rb\nAudited.audit_class.as_user(\"console-user-#{ENV['SSH_USER']}\") do\n  post.update_attributes!(title: \"Hello, world!\")\nend\npost.audits.last.user # => 'console-user-username'\n```\n\nIf you want to set a specific user as the auditor of the commands in a CLI environment, whether that is a string or an ActiveRecord object, you can use the following command:\n\n```rb\nAudited.store[:audited_user] = \"username\"\n\n# or\n\nAudited.store[:audited_user] = User.find(1)\n```\n\n### Associated Audits\n\nSometimes it's useful to associate an audit with a model other than the one being changed. For instance, given the following models:\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  belongs_to :company\n  audited\nend\n\nclass Company \u003C ActiveRecord::Base\n  has_many :users\nend\n```\n\nEvery change to a user is audited, but what if you want to grab all of the audits of users belonging to a particular company? You can add the `:associated_with` option to your `audited` call:\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  belongs_to :company\n  audited associated_with: :company\nend\n\nclass Company \u003C ActiveRecord::Base\n  audited\n  has_many :users\n  has_associated_audits\nend\n```\n\nNow, when an audit is created for a user, that user's company is also saved alongside the audit. This makes it much easier (and faster) to access audits indirectly related to a company.\n\n```ruby\ncompany = Company.create!(name: \"Collective Idea\")\nuser = company.users.create!(name: \"Steve\")\nuser.update!(name: \"Steve Richert\")\nuser.audits.last.associated # => #\u003CCompany name: \"Collective Idea\">\ncompany.associated_audits.last.auditable # => #\u003CUser name: \"Steve Richert\">\n```\n\nYou can access records' own audits and associated audits in one go:\n```ruby\ncompany.own_and_associated_audits\n```\n\n### Conditional auditing\n\nIf you want to audit only under specific conditions, you can provide conditional options (similar to ActiveModel callbacks) that will ensure your model is only audited for these conditions.\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  audited if: :active?\n\n  def active?\n    last_login > 6.months.ago\n  end\nend\n```\n\nJust like in ActiveModel, you can use an inline Proc in your conditions:\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  audited unless: Proc.new { |u| u.ninja? }\nend\n```\n\nIn the above case, the user will only be audited when `User#ninja` is `false`.\n\n### Disabling auditing\n\nIf you want to disable auditing temporarily doing certain tasks, there are a few\nmethods available.\n\nTo disable auditing on a save:\n\n```ruby\n@user.save_without_auditing\n```\n\nor:\n\n```ruby\n@user.without_auditing do\n  @user.save\nend\n```\n\nTo disable auditing on a column:\n\n```ruby\nUser.non_audited_columns = [:first_name, :last_name]\n```\n\nTo disable auditing on an entire model:\n\n```ruby\nUser.auditing_enabled = false\n```\n\nTo disable auditing on all models:\n\n```ruby\nAudited.auditing_enabled = false\n```\n\nIf you have auditing disabled by default on your model you can enable auditing\ntemporarily.\n\n```ruby\nUser.auditing_enabled = false\n@user.save_with_auditing\n```\n\nor:\n\n```ruby\nUser.auditing_enabled = false\n@user.with_auditing do\n  @user.save\nend\n```\n\n### Encrypted attributes\n\nIf you're using ActiveRecord's encryption (available from Rails 7) to encrypt some attributes, Audited will automatically filter values of these attributes. No additional configuration is required. Changes to encrypted attributes will be logged as `[FILTERED]`.\n\n```ruby\nclass User \u003C ActiveRecord::Base\n  audited\n  encrypts :password\nend\n```\n\n### Custom `Audit` model\n\nIf you want to extend or modify the audit model, create a new class that\ninherits from `Audited::Audit`:\n```ruby\nclass CustomAudit \u003C Audited::Audit\n  def some_custom_behavior\n    \"Hiya!\"\n  end\nend\n```\nThen set it in an initializer:\n```ruby\n# config\u002Finitializers\u002Faudited.rb\n\nAudited.config do |config|\n  config.audit_class = \"CustomAudit\"\nend\n```\n\n### Enum Storage\n\nIn 4.10, the default behavior for enums changed from storing the value synthesized by Rails to the value stored in the DB. You can restore the previous behavior by setting the store_synthesized_enums configuration value:\n\n```ruby\n# config\u002Finitializers\u002Faudited.rb\n\nAudited.store_synthesized_enums = true\n```\n\n## Support\n\nYou can find documentation at: https:\u002F\u002Fwww.rubydoc.info\u002Fgems\u002Faudited\n\nOr join the [mailing list](http:\u002F\u002Fgroups.google.com\u002Fgroup\u002Faudited) to get help or offer suggestions.\n\n## Contributing\n\nIn the spirit of [free software](http:\u002F\u002Fwww.fsf.org\u002Flicensing\u002Fessays\u002Ffree-sw.html), **everyone** is encouraged to help improve this project. Here are a few ways _you_ can pitch in:\n\n* Use prerelease versions of Audited.\n* [Report bugs](https:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Faudited\u002Fissues).\n* Fix bugs and submit [pull requests](http:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Faudited\u002Fpulls).\n* Write, clarify or fix documentation.\n* Refactor code.\n","Audited 是一个用于 Rails 应用的 ORM 扩展，它能够记录模型的所有更改。其核心功能包括自动记录数据变更、支持记录变更者信息、保存变更备注以及关联相关模型。技术上，Audited 专为 ActiveRecord 设计，并且支持多种 Ruby 版本和 Rails 版本（从 3.0 到 7.2），确保了广泛的兼容性。此外，它还提供了灵活的配置选项来适应不同的数据库类型与用户需求。此工具非常适合需要跟踪重要业务数据修改历史的应用场景，如财务系统、内容管理系统等，有助于提高系统的可追溯性和安全性。",2,"2026-06-11 03:14:41","top_language"]