record_history 0.8.2 → 0.8.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/README.md +48 -0
- data/lib/record_history/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# record_history
|
|
2
|
+
|
|
3
|
+
ActiveRecord history
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
gem install record_history
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
# activate history logging for model
|
|
14
|
+
class Item < ActiveRecord::Base
|
|
15
|
+
has_record_history
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# activate history logging for model (only for "name" field)
|
|
19
|
+
class Item < ActiveRecord::Base
|
|
20
|
+
has_record_history :only => [:name]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# activate history logging for model (except 'name' field)
|
|
24
|
+
class Item < ActiveRecord::Base
|
|
25
|
+
has_record_history :ignore => [:name]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# activate history logging for model (on update)
|
|
29
|
+
class Item < ActiveRecord::Base
|
|
30
|
+
has_record_history :on => [:update]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# get history for object
|
|
34
|
+
item = Item.first
|
|
35
|
+
history = item.first.record_history
|
|
36
|
+
history.first.old_value
|
|
37
|
+
hostory.first.new_value
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# declare that User is author for some record_history items
|
|
41
|
+
class User < ActiveRecord::Base
|
|
42
|
+
is_record_history_author
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# get record_history items created by user
|
|
46
|
+
User.first.written_history
|
|
47
|
+
|
|
48
|
+
|