action_logger 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  module ActionLogsHelper
2
2
  def log_action action, source, attrs = {}
3
- attrs[:sender] || try(:current_user)
4
- attrs[:ip] || request.try(:remote_ip)
5
- attrs[:data] || params
6
- attrs[:admin_id] || try(:current_admin_user)
3
+ attrs[:sender] ||= try(:current_user)
4
+ attrs[:ip] ||= request.try(:remote_ip)
5
+ attrs[:data] ||= params
6
+ attrs[:admin_id] ||= try(:current_admin_user)
7
7
 
8
8
  ActionLogger.log action, source, attrs
9
9
  end
@@ -1,7 +1,8 @@
1
1
  class ActionLog < ActiveRecord::Base
2
+ belongs_to :sender, polymorphic: true
2
3
  serialize :data
3
4
 
4
5
  def self.log action, source, sender = nil, ip = nil, data = {}, admin_id = nil
5
- create! action: action, source: source, sender_id: sender.try(:id), sender_type: sender.try(:class).try(:name), ip: ip, data: data, admin_id: (admin_id.present? && admin_id.respond_to?(:id) ? admin_id.id : admin_id)
6
+ create! action: action, source: source, sender: sender, ip: ip, data: data, admin_id: (admin_id.present? && admin_id.respond_to?(:id) ? admin_id.id : admin_id)
6
7
  end
7
8
  end
@@ -3,6 +3,6 @@ require 'action_logger/engine'
3
3
 
4
4
  module ActionLogger
5
5
  def self.log action, source, attrs = {}
6
- ActionLog.log action, source, attrs[:semder], attrs[:ip], attrs[:data], attrs[:admin_id]
6
+ ActionLog.log action, source, attrs[:sender], attrs[:ip], attrs[:data], attrs[:admin_id]
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module ActionLogger
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-17 00:00:00.000000000 Z
12
+ date: 2012-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails