audit_rails 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +14 -9
- data/app/assets/javascripts/audit_rails/audit.js +1 -1
- data/lib/audit_rails/version.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -16,15 +16,16 @@ gem ‘audit_rails’
|
|
16
16
|
|
17
17
|
rails g audit_rails:install
|
18
18
|
|
19
|
-
|
19
|
+
= Usage
|
20
|
+
=== To add audit migration:
|
20
21
|
|
21
22
|
rake audit_rails:install:migrations
|
22
23
|
|
23
|
-
|
24
|
+
=== Add audit.js to application.js file:
|
24
25
|
|
25
26
|
//= require audit_rails/audit
|
26
27
|
|
27
|
-
|
28
|
+
=== To add additional attributes to Audit (let's say book_id):
|
28
29
|
1. Add attributes to migration generated from above rake task
|
29
30
|
2. Inherit from AuditRails::Audit:
|
30
31
|
#MyApp/app/models/audit.rb
|
@@ -36,19 +37,23 @@ rake audit_rails:install:migrations
|
|
36
37
|
belongs_to :book
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
+
=== To log user events
|
41
|
+
Simply call 'add_to_audit' with desired parameters in any controller (as this is now a helper method included in application_controller.rb of application)
|
40
42
|
|
41
|
-
|
43
|
+
=== To override controller's add_to_audit method (or the helper method)
|
44
|
+
Simply re-implement in application_controller.rb
|
42
45
|
|
43
|
-
|
46
|
+
=== To track user login (one per day)
|
47
|
+
Override current_user method in application controller, e.g.:
|
44
48
|
def current_user
|
45
49
|
add_to_audit('login', 'sessions', "John Smith")
|
46
50
|
super
|
47
51
|
end
|
48
52
|
|
49
|
-
|
53
|
+
=== To see all audits
|
54
|
+
Go to <app-url>/audit_rails/audits
|
50
55
|
|
51
|
-
|
56
|
+
=== To download the audit report as xls file:
|
52
57
|
* Add this to initializers/mime_types.rb
|
53
58
|
Mime::Type.register "application/vnd.ms-excel", :xls
|
54
59
|
|
@@ -65,4 +70,4 @@ You are welcome to contribute and add more feature to this gem. I have added rsp
|
|
65
70
|
Please fork it, add specs and send a pull request!
|
66
71
|
|
67
72
|
= License
|
68
|
-
This project rocks and uses MIT-LICENSE.
|
73
|
+
This project rocks and uses MIT-LICENSE.
|
data/lib/audit_rails/version.rb
CHANGED