changes 0.0.2 → 0.1.0

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.markdown ADDED
@@ -0,0 +1,53 @@
1
+ Changes
2
+ ============================================================
3
+
4
+ Changes is a gem that logs the changes in your models after you update the values. Let's say you do a
5
+
6
+ @model = MyModel.create(:amount => 99)
7
+
8
+ Then after
9
+
10
+ @model.update_attribute(:amount => 100)
11
+
12
+ Then you can see the changes
13
+
14
+ @model.show_changes
15
+
16
+ Which will return
17
+
18
+ ["Amount changed from 99.0 to 100.0\n"]
19
+
20
+ Requirements
21
+ ------------
22
+
23
+ * Rails 3.x (Not tested with Rails 3.1)
24
+
25
+ Installation
26
+ ------------
27
+
28
+ In your gemfile:
29
+
30
+ gem 'changes'
31
+
32
+ After running a 'bundle install' you need to generate the migrations file
33
+
34
+ rails generate changes
35
+
36
+ License
37
+ -------
38
+
39
+ This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
40
+
41
+ Usage
42
+ =====
43
+
44
+ In the model where you wish to log the changes, when updating. You add
45
+
46
+ has_changes
47
+
48
+ Then after an update you can do
49
+
50
+ @updated_model.show_changes
51
+
52
+ And the changes will be listed with before and after values
53
+
@@ -1,6 +1,5 @@
1
1
  module Changes
2
2
  class ResourceChange < ActiveRecord::Base
3
3
  belongs_to :logged_resource, :polymorphic => true
4
-
5
4
  end
6
5
  end
@@ -1,3 +1,3 @@
1
1
  module Changes
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  class CreateChangesTable < ActiveRecord::Migration
2
2
  def self.up
3
- create_table :changes, :force => true do |t|
3
+ create_table :resource_changes, :force => true do |t|
4
4
  t.text :log_changed
5
5
  t.text :log_changes
6
6
  t.string :logged_resource_type
@@ -15,7 +15,7 @@ module Changes
15
15
  # This is where arbitrary code goes that you want to
16
16
  # add to the class that declared "acts_as_widget"
17
17
 
18
- has_many :resource_changes, :as => :logged_resource, :class_name => 'Changes::ResourceChange'
18
+ has_many :resource_changes, :as => :logged_resource, :class_name => 'Changes::ResourceChange', :dependent => :destroy
19
19
  before_save :identify_changes
20
20
 
21
21
  include Changes::RecordChanges::Base::InstanceMethods
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jesper Christiansen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-23 00:00:00 Z
18
+ date: 2011-07-24 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Adds logging of changes to your model, so you can see a list of changes - and what the values were changed from
@@ -30,6 +30,7 @@ extra_rdoc_files: []
30
30
  files:
31
31
  - .gitignore
32
32
  - Gemfile
33
+ - README.markdown
33
34
  - Rakefile
34
35
  - app/models/changes/resource_change.rb
35
36
  - changes.gemspec