Module: AppmospheresAudit::ControllerTrail::ClassMethods

Defined in:
lib/appmospheres_audit.rb

Instance Method Summary collapse

Instance Method Details

#enable_action_trackingObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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