Doesn not work audited 4.7 gem for updating model

319 views Asked by At

I am new to rails and I used audited 4.7 gem for my rails application to track loggers. I have no idea how do I add a comment to audit table record. thank you

Gemfile

gem "audited", "~> 4.7"

Model

class Client < ApplicationRecord

    audit
1

There are 1 answers

4
widjajayd On
# add to your Gemfile, and run bundle install to install it
gem "audited"

# install table for audited gem operation
rails generate audited:install
rails db:migrate

# open your model that you want to audited
class Client < ApplicationRecord
  audit
end
# restart rails server

# how to check the action 
@client = Client.first
@audits = @client.audits
if @audits
  @audits.each do |audit| 
    if audit.user
      audit.user.username
      audit.action
    end
  end              
end