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.
- data/app/helpers/action_logs_helper.rb +4 -4
- data/app/models/action_log.rb +2 -1
- data/lib/action_logger.rb +1 -1
- data/lib/action_logger/version.rb +1 -1
- metadata +2 -2
@@ -1,9 +1,9 @@
|
|
1
1
|
module ActionLogsHelper
|
2
2
|
def log_action action, source, attrs = {}
|
3
|
-
attrs[:sender]
|
4
|
-
attrs[:ip]
|
5
|
-
attrs[:data]
|
6
|
-
attrs[:admin_id]
|
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
|
data/app/models/action_log.rb
CHANGED
@@ -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,
|
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
|
data/lib/action_logger.rb
CHANGED
@@ -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[:
|
6
|
+
ActionLog.log action, source, attrs[:sender], attrs[:ip], attrs[:data], attrs[:admin_id]
|
7
7
|
end
|
8
8
|
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.
|
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-
|
12
|
+
date: 2012-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|