Sha256: 2a9170e104bceb3ee94ba36ad420cd702e5e5c425fa84dcabff96f40ef63a9f8

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

require_dependency "audit_rails/application_controller"
require 'to_xls' #TODO: need to figure out why this has to be required when it is in dependency

module AuditRails
  class AuditsController < ApplicationController

    def index
      @audits = AuditRails::Audit.all
      
      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @audits }
        format.xls { send_data @audits.to_xls(:columns => [:user_name, :action, :description, :created_at], 
          :headers => ['User name', 'Action', 'Details', 'When?']), filename: 'audits.xls'}

      end
    end

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
audit_rails-0.1.2 app/controllers/audit_rails/audits_controller.rb
audit_rails-0.1.1 app/controllers/audit_rails/audits_controller.rb
audit_rails-0.1.0 app/controllers/audit_rails/audits_controller.rb