change_log 0.0.2 → 0.0.3
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/.gitignore +1 -0
- data/lib/change_log/version.rb +1 -1
- metadata +3 -5
- data/.change_log.gemspec.un~ +0 -0
- data/README +0 -69
data/.gitignore
CHANGED
data/lib/change_log/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: change_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Peter Zhang
|
@@ -42,11 +42,9 @@ extensions: []
|
|
42
42
|
extra_rdoc_files: []
|
43
43
|
|
44
44
|
files:
|
45
|
-
- .change_log.gemspec.un~
|
46
45
|
- .gitignore
|
47
46
|
- Gemfile
|
48
47
|
- MIT-LICENSE
|
49
|
-
- README
|
50
48
|
- Rakefile
|
51
49
|
- change_log.gemspec
|
52
50
|
- lib/change_log.rb
|
data/.change_log.gemspec.un~
DELETED
Binary file
|
data/README
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
h1. Change Log
|
2
|
-
|
3
|
-
A gem to keep all maintenances in database
|
4
|
-
|
5
|
-
|
6
|
-
h2. Install Change Log Gem
|
7
|
-
1. command:
|
8
|
-
<pre><code># gem install change_log</code</pre>
|
9
|
-
|
10
|
-
2. bundler
|
11
|
-
<pre><code>
|
12
|
-
# Gemfile in your application
|
13
|
-
gem 'change_log','0.0.1'
|
14
|
-
</code</pre>
|
15
|
-
then:
|
16
|
-
<pre><code>
|
17
|
-
bundle install
|
18
|
-
</code</pre>
|
19
|
-
|
20
|
-
h2. Create a table to keep all maintenance logs
|
21
|
-
|
22
|
-
1. generate a migration file
|
23
|
-
|
24
|
-
<pre><code>
|
25
|
-
class AddChangeLog < ActiveRecord::Migration
|
26
|
-
def self.up
|
27
|
-
create_table :change_log do |t|
|
28
|
-
t.integer :version, :null=>false # store version of each change
|
29
|
-
t.string :record_id,:limit=>30 # store the actual record id
|
30
|
-
t.string :table_name, :limti=>60 # store the table name
|
31
|
-
t.string :attribute_name,:limit=>60 # store the column name
|
32
|
-
t.string :user, :limit=>20 # store the user who made the change
|
33
|
-
t.string :action, :limit=>6 # store the change action: create, read, update, delete
|
34
|
-
t.text :old_value # the value before change
|
35
|
-
t.text :new_value # value after change
|
36
|
-
t.string :field_type, :limit=>30 # the column type eg. date, text, varchar, int etc
|
37
|
-
t.timestamps
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.down
|
42
|
-
drop_table :change_log
|
43
|
-
end
|
44
|
-
end
|
45
|
-
</code></pre>
|
46
|
-
|
47
|
-
Then:
|
48
|
-
<pre><code>rake db:migrate</code></pre>
|
49
|
-
|
50
|
-
h2. Use Change Log
|
51
|
-
1. Add current_user method in application_controller.rb
|
52
|
-
<pre><code>
|
53
|
-
# used by change log
|
54
|
-
def current_user # :nodoc:
|
55
|
-
return session[:user] # replace this with your own code to tell change_log who is the current user
|
56
|
-
end
|
57
|
-
</code></pre>
|
58
|
-
|
59
|
-
h2. Testing
|
60
|
-
TODO::
|
61
|
-
|
62
|
-
|
63
|
-
Author
|
64
|
-
------
|
65
|
-
|
66
|
-
Peter Zhang at NCS New Zealand.
|
67
|
-
Email: peterz@ncs.co.nz
|
68
|
-
|
69
|
-
Copyright (c) 2011 Peter Zhang, released under the MIT license
|