From 14c9eb6b6c6f927bd4955b528cfdb8ab947e9dbb Mon Sep 17 00:00:00 2001 From: qinmingyuan Date: Thu, 30 Nov 2023 17:19:32 +0800 Subject: [PATCH] audit --- Gemfile.lock | 6 +++--- app/controllers/auditor/controller/application.rb | 4 ++-- app/models/auditor/ext/audited.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2b537d9..c856642 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/work-design/rails_com.git - revision: 812e1cad5b9864947f7ccf7a02248670fc91b068 + revision: 48dc213af87f1f5e5627ee1bee6206d5cf405d1a specs: rails_com (1.3.0) acme-client @@ -18,14 +18,14 @@ GIT GIT remote: https://github.com/work-design/rails_design.git - revision: 325fbdffd6b43820039ebab4da8dd60fea568187 + revision: e1a2ab2314a882985e48502648af4d5aed2244eb specs: rails_design (0.0.1) rails GIT remote: https://github.com/work-design/rails_extend.git - revision: 075daf9b8da63a99cfcea45f91eb51e2cf3276b2 + revision: e8f39cb7529b55cda4eb8b5e4d69fb63ec998168 specs: rails_extend (1.0.1) rails (>= 5.0) diff --git a/app/controllers/auditor/controller/application.rb b/app/controllers/auditor/controller/application.rb index 96173f5..3219142 100644 --- a/app/controllers/auditor/controller/application.rb +++ b/app/controllers/auditor/controller/application.rb @@ -2,7 +2,7 @@ module Auditor module Controller::Application # after_action - def mark_audits(instance: [], local: [], binding:, **options) + def mark_audits(instance: [], local: [], bind: binding, **options) instance_records = Array(instance).map!(&:to_sym) & valid_ivars instance_records.each do |ivar| record = instance_variable_get(ivar) @@ -12,7 +12,7 @@ def mark_audits(instance: [], local: [], binding:, **options) local_records = Array(local).map!(&:to_sym) & local_variables local_records.each do |ivar| - record = binding.local_variable_get(ivar) + record = bind.local_variable_get(ivar) next unless record.is_a?(ActiveRecord::Base) save_audits(record, **options) end diff --git a/app/models/auditor/ext/audited.rb b/app/models/auditor/ext/audited.rb index b1f8e77..02eb82d 100644 --- a/app/models/auditor/ext/audited.rb +++ b/app/models/auditor/ext/audited.rb @@ -46,7 +46,7 @@ def save_audits(operator:, only: [], except: [], include: [], **extra_options) audit.operator_type = operator.class.name audit.operator_id = operator.id - audit.assign_attributes = extra_options.except!(:note, :controller_path, :action_name, :remote_ip) + audit.assign_attributes extra_options.except!(:note, :controller_path, :action_name, :remote_ip) audit.extra = extra_options audit.save end