module AppmospheresAudit::ControllerTrail::ClassMethods

Public Instance Methods

enable_action_tracking() click to toggle source
# File lib/appmospheres_audit.rb, line 96
def enable_action_tracking
  around_filter do |controller, action|
    begin
      begin
        filtered_actions = AppmospheresAudit.filter_actions || []
        unless filtered_actions.include?(controller.action_name.to_sym) || filtered_actions.include?(controller.action_name)
          filtered_params = Rails.application.config.filter_parameters + (AppmospheresAudit.filter_parameters || [])
          EventLog.create!(:event_type => 'controller', :action => controller.request.parameters[:action],
            :payload => controller.request.parameters.except(*filtered_params).to_yaml)
        end
      rescue
        Rails.logger.warn "tracked #{controller.request.parameters.inspect}" rescue nil
      end
      action.call
    rescue Exception => e
      log_exception(e)
      raise # again, so the execution continues as intended by the app
    end
  end
end