README.md in audited-5.0.2 vs README.md in audited-5.1.0
- old
+ new
@@ -1,10 +1,9 @@
Audited
[![Gem Version](https://img.shields.io/gem/v/audited.svg)](http://rubygems.org/gems/audited)
![Build Status](https://github.com/collectiveidea/audited/actions/workflows/ci.yml/badge.svg)
[![Code Climate](https://codeclimate.com/github/collectiveidea/audited.svg)](https://codeclimate.com/github/collectiveidea/audited)
-[![Security](https://hakiri.io/github/collectiveidea/audited/master.svg)](https://hakiri.io/github/collectiveidea/audited/master)
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
=======
**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.
@@ -16,16 +15,17 @@
## Supported Rubies
Audited supports and is [tested against](https://github.com/collectiveidea/audited/actions/workflows/ci.yml) the following Ruby versions:
-* 2.3
+* 2.3 (only tested on Sqlite due to testing issues with other DBs)
* 2.4
* 2.5
* 2.6
* 2.7
* 3.0
+* 3.1
Audited 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://github.com/collectiveidea/audited/pulls).
## Supported ORMs
@@ -217,11 +217,11 @@
```
Outside of a request, Audited can still record the user with the `as_user` method:
```ruby
-Audited.audit_class.as_user(User.find(1)) do
+Audited.audit_model.as_user(User.find(1)) do
post.update!(title: "Hello, world!")
end
post.audits.last.user # => #<User id: 1>
```
@@ -244,11 +244,11 @@
```
`as_user` also accepts a string, which can be useful for auditing updates made in a CLI environment:
```rb
-Audited.audit_class.as_user("console-user-#{ENV['SSH_USER']}") do
+Audited.audit_model.as_user("console-user-#{ENV['SSH_USER']}") do
post.update_attributes!(title: "Hello, world!")
end
post.audits.last.user # => 'console-user-username'
```
@@ -284,10 +284,11 @@
belongs_to :company
audited associated_with: :company
end
class Company < ActiveRecord::Base
+ audited
has_many :users
has_associated_audits
end
```
@@ -311,13 +312,11 @@
If 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.
```ruby
class User < ActiveRecord::Base
audited if: :active?
-
- private
-
+
def active?
last_login > 6.months.ago
end
end
```
@@ -384,10 +383,21 @@
@user.with_auditing do
@user.save
end
```
+### Encrypted attributes
+
+If 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]`.
+
+```ruby
+class User < ActiveRecord::Base
+ audited
+ encrypts :password
+end
+```
+
### Custom `Audit` model
If you want to extend or modify the audit model, create a new class that
inherits from `Audited::Audit`:
```ruby
@@ -400,10 +410,10 @@
Then set it in an initializer:
```ruby
# config/initializers/audited.rb
Audited.config do |config|
- config.audit_class = CustomAudit
+ config.audit_class = "CustomAudit"
end
```
### Enum Storage