Basic Usage of Audited
mainTo enable auditing on an ActiveRecord model, call the audited method within the class definition. By default, Audited tracks create, update, touch (Rails 6+), and destroy actions, recording what changed in the audited_changes hash.
class User < ActiveRecord::Base
audited
end
# Usage
user = User.create!(name: "Steve")
user.update!(name: "Ryan")
audit = user.audits.last
puts audit.action # => "update"
puts audit.audited_changes # => {"name"=>["Steve", "Ryan"]}