action_logger 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/helpers/action_logs_helper.rb +5 -0
- data/app/models/action_log.rb +1 -2
- data/lib/action_logger.rb +0 -5
- data/lib/action_logger/version.rb +1 -1
- metadata +1 -7
@@ -1,5 +1,10 @@
|
|
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)
|
7
|
+
|
3
8
|
ActionLogger.log action, source, attrs
|
4
9
|
end
|
5
10
|
end
|
data/app/models/action_log.rb
CHANGED
@@ -2,7 +2,6 @@ class ActionLog < ActiveRecord::Base
|
|
2
2
|
serialize :data
|
3
3
|
|
4
4
|
def self.log action, source, sender = nil, ip = nil, data = {}, admin_id = nil
|
5
|
-
|
6
|
-
Rails.logger.info log.inspect
|
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)
|
7
6
|
end
|
8
7
|
end
|
data/lib/action_logger.rb
CHANGED
@@ -3,11 +3,6 @@ require 'action_logger/engine'
|
|
3
3
|
|
4
4
|
module ActionLogger
|
5
5
|
def self.log action, source, attrs = {}
|
6
|
-
attrs[:sender] || try(:current_user)
|
7
|
-
attrs[:ip] || request.try(:remote_ip)
|
8
|
-
attrs[:data] || params
|
9
|
-
attrs[:admin_id] || try(:current_admin_user)
|
10
|
-
|
11
6
|
ActionLog.log action, source, attrs[:semder], attrs[:ip], attrs[:data], attrs[:admin_id]
|
12
7
|
end
|
13
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.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -58,18 +58,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- - ! '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
hash: 3345375381320870001
|
64
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
62
|
none: false
|
66
63
|
requirements:
|
67
64
|
- - ! '>='
|
68
65
|
- !ruby/object:Gem::Version
|
69
66
|
version: '0'
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
hash: 3345375381320870001
|
73
67
|
requirements: []
|
74
68
|
rubyforge_project:
|
75
69
|
rubygems_version: 1.8.24
|