Sha256: 84bec82bb1791382f3302e72eba67ca751a4a16d623dc8050aafd58cda73f112

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module AuditRails
  module AuditsHelper
    def add_to_audit(action_name=nil, controller_name=nil, user_name=nil, description=nil)
      if (action_name == "login" && 
              AuditRails::Audit.no_audit_entry_for_today?(action_name, user_name)) || 
        action_name != "login"
          AuditRails::Audit.create(action: get_action(action_name), 
            controller: controller_name || request.params[:controller], 
            user_name: user_name, 
            description: description,
            ip_address: request.remote_ip.to_s)
      end
    end

    def get_action(action_name)
      action_name || request.params[:action]
    end

    def active?(action_name)
      controller.action_name == action_name
    end

    def active_class(action_name)
      active?(action_name) ? 'active' : ''
    end

    def page_visits_by_user(user)
      JSON.parse(@analysis[:per_user_by_page_views])[user].to_json
    end

    def percentage_share(user, count, total)
      "#{(100.0 * count/total).round(1)}%"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
audit_rails-2.0.10 app/helpers/audit_rails/audits_helper.rb
audit_rails-2.0.9 app/helpers/audit_rails/audits_helper.rb