Class: AuditRails::AuditsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/audit_rails/audits_controller.rb

Instance Method Summary collapse

Methods included from AuditsHelper

#active?, #active_class, #add_to_audit, #page_visits_by_user, #percentage_share

Instance Method Details

#analyticsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/audit_rails/audits_controller.rb', line 21

def analytics
  @analysis_by_user_name  = AuditRails::Audit.in_range(@range_begin, @range_end).analysis_by_user_name
  @analysis_by_page_views = AuditRails::Audit.in_range(@range_begin, @range_end).analysis_by_page_views
  @analysis_per_user_by_page_views  = AuditRails::Audit.in_range(@range_begin, @range_end).analysis_per_user_by_page_views

  @total = AuditRails::Audit.in_range(@range_begin, @range_end).count
  @no_audits = AuditRails::Audit.count == 0

  if params[:commit] == "Download Filtered Report"
    find_all_audits
    send_data(@audits.to_xls(:columns => [:user_name, :action, :description, :created_at], 
              :headers => ['User name', 'Action', 'Details', 'When?']), filename: 'audits.xls') and return
  end
end

#createObject



16
17
18
19
# File 'app/controllers/audit_rails/audits_controller.rb', line 16

def create
  add_to_audit("visit-site", "xyz", "Fake User")
  render :nothing => true, :status => 200, :content_type => 'text/html'
end

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/audit_rails/audits_controller.rb', line 7

def index
  find_all_audits

  if params[:commit] == "Download Filtered Report"
    send_data(@audits.to_xls(:columns => [:user_name, :action, :description, :created_at], 
              :headers => ['User name', 'Action', 'Details', 'When?']), filename: 'audits.xls') and return
  end
end