audit_rails 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +23 -11
- data/app/controllers/audit_rails/audits_controller.rb +5 -1
- data/lib/audit_rails/version.rb +1 -1
- data/test/dummy/log/development.log +3 -0
- metadata +21 -5
data/README.rdoc
CHANGED
@@ -27,22 +27,34 @@ rake audit_rails:install:migrations
|
|
27
27
|
* To add additional attributes to Audit (let's say book_id):
|
28
28
|
1. Add attributes to migration generated from above rake task
|
29
29
|
2. Inherit from AuditRails::Audit:
|
30
|
-
#MyApp/app/models/audit.rb
|
31
|
-
class Audit < AuditRails::Audit
|
32
|
-
|
33
|
-
|
30
|
+
#MyApp/app/models/audit.rb
|
31
|
+
class Audit < AuditRails::Audit
|
32
|
+
attr_accessible :action, :controller, :description, :user_name,
|
33
|
+
:book_id
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
35
|
+
#add associations as usual:
|
36
|
+
belongs_to :book
|
37
|
+
end
|
38
38
|
|
39
39
|
* To override controller's add_to_audit method (or the helper method), simply re-implement in application_controller.rb
|
40
40
|
|
41
41
|
* To track user login (one per day), override current_user method in application controller, e.g.:
|
42
|
-
def current_user
|
43
|
-
|
44
|
-
|
45
|
-
end
|
42
|
+
def current_user
|
43
|
+
add_to_audit('login', 'sessions', "John Smith")
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
* To see all audits go to <app-url>/audit_rails/audits
|
48
|
+
|
49
|
+
* To download the audit report as xls file:
|
50
|
+
* Add this to initializers/mime_types.rb
|
51
|
+
Mime::Type.register "application/vnd.ms-excel", :xls
|
52
|
+
|
53
|
+
* Use below link in views:
|
54
|
+
link_to audit_rails.audits_path(:format => "xls")
|
55
|
+
|
56
|
+
= Changelog
|
57
|
+
https://github.com/gouravtiwari/audit_rails/blob/master/README.rdoc
|
46
58
|
|
47
59
|
= Contribute
|
48
60
|
|
@@ -1,14 +1,18 @@
|
|
1
1
|
require_dependency "audit_rails/application_controller"
|
2
|
+
require 'to_xls' #TODO: need to figure out why this has to be required when it is in dependency
|
2
3
|
|
3
4
|
module AuditRails
|
4
5
|
class AuditsController < ApplicationController
|
5
6
|
|
6
7
|
def index
|
7
8
|
@audits = AuditRails::Audit.all
|
8
|
-
|
9
|
+
|
9
10
|
respond_to do |format|
|
10
11
|
format.html # index.html.erb
|
11
12
|
format.json { render json: @audits }
|
13
|
+
format.xls { send_data @audits.to_xls(:columns => [:user_name, :action, :description, :created_at],
|
14
|
+
:headers => ['User name', 'Action', 'Details', 'When?']), filename: 'audits.xls'}
|
15
|
+
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
data/lib/audit_rails/version.rb
CHANGED
@@ -252,3 +252,6 @@ Connecting to database specified by database.yml
|
|
252
252
|
[1m[35m (0.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
253
253
|
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
254
254
|
[1m[35m (0.9ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20121213191242')
|
255
|
+
Connecting to database specified by database.yml
|
256
|
+
Connecting to database specified by database.yml
|
257
|
+
Connecting to database specified by database.yml
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: audit_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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-12-
|
12
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.2.9
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: to_xls
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.5.1
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.5.1
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: sqlite3
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,9 +75,8 @@ dependencies:
|
|
59
75
|
- - ~>
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: 2.12.0
|
62
|
-
description:
|
63
|
-
|
64
|
-
audit link tracking. This gem just serve this purpose.
|
78
|
+
description: An action based auditor, which has internal as well as outgoing link
|
79
|
+
tracking.
|
65
80
|
email:
|
66
81
|
- gouravtiwari21@gmail.com
|
67
82
|
executables: []
|
@@ -185,3 +200,4 @@ test_files:
|
|
185
200
|
- test/dummy/script/rails
|
186
201
|
- test/integration/navigation_test.rb
|
187
202
|
- test/test_helper.rb
|
203
|
+
has_rdoc:
|