change_log 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.textile +6 -6
- data/change_log.gemspec +1 -0
- data/lib/change_log/change_logs.rb +5 -1
- data/lib/change_log/version.rb +1 -1
- metadata +19 -3
data/Gemfile
CHANGED
data/README.textile
CHANGED
@@ -78,7 +78,7 @@ If you are making changes within Model file:
|
|
78
78
|
For Example:
|
79
79
|
<pre><code># this is a model file
|
80
80
|
def making_some_changes
|
81
|
-
user = User.
|
81
|
+
user = User.first
|
82
82
|
user.email = 'peterz@ncs.co.nz'
|
83
83
|
user.save
|
84
84
|
end
|
@@ -88,7 +88,7 @@ An attribute called 'whodidit' is automatically available.
|
|
88
88
|
So if you want to keep the changes in this scenario, do following:
|
89
89
|
<pre><code># this is a model file
|
90
90
|
def making_some_changes
|
91
|
-
user = User.
|
91
|
+
user = User.first
|
92
92
|
user.email = 'peterz@ncs.co.nz'
|
93
93
|
user.whodidit = 'Peter'
|
94
94
|
user.save
|
@@ -102,18 +102,18 @@ You can use it directly in your model, controller even in helper.
|
|
102
102
|
|
103
103
|
For example:
|
104
104
|
<pre><code># List all changes
|
105
|
-
ChangeLogs.
|
105
|
+
ChangeLogs.all</code></pre>
|
106
106
|
|
107
107
|
<pre><code># List all changes made by user 'peterz'
|
108
|
-
ChangeLogs.
|
108
|
+
ChangeLogs.where('user = ?', 'peterz')</code></pre>
|
109
109
|
|
110
110
|
<pre><code># List all changes for table 'accounts'
|
111
|
-
ChangeLogs.
|
111
|
+
ChangeLogs.where('table_name = ?', 'accounts')</code></pre>
|
112
112
|
|
113
113
|
4. *Turn ChangeLogs off in testing environment*
|
114
114
|
You can globally turn it off for your testing.
|
115
115
|
<pre><code># config/environment.rb
|
116
|
-
ChangeLog.enabled = false if
|
116
|
+
ChangeLog.enabled = false if Rails.env.test?
|
117
117
|
</code></pre>
|
118
118
|
|
119
119
|
5. *Database and table name*
|
data/change_log.gemspec
CHANGED
@@ -18,4 +18,5 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
|
+
s.add_dependency('activerecord-import', '0.3.1')
|
21
22
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
require 'activerecord-import'
|
2
|
+
|
1
3
|
class ChangeLogs < ActiveRecord::Base
|
2
4
|
# Set table name to "change_logs"
|
3
5
|
self.table_name = :change_logs
|
4
6
|
|
7
|
+
attr_accessible :action, :record_id, :table_name, :user, :field_type, :attribute_name, :old_value, :new_value, :version
|
8
|
+
|
5
9
|
private
|
6
10
|
|
7
11
|
# Save Change Log details with changes
|
@@ -14,7 +18,7 @@ class ChangeLogs < ActiveRecord::Base
|
|
14
18
|
record.created_at = Time.now
|
15
19
|
records << record
|
16
20
|
end
|
17
|
-
ChangeLogs.import records
|
21
|
+
ChangeLogs.import records, :validate => false
|
18
22
|
end
|
19
23
|
|
20
24
|
# return the latest version number for this change
|
data/lib/change_log/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: change_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
13
|
-
dependencies:
|
12
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord-import
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.3.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.1
|
14
30
|
description: A gem for tracking who did what and when it happened -- keeps all the
|
15
31
|
changes done by user into a maintenance log
|
16
32
|
email:
|