has_audit_trail 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require File.expand_path('../lib/has_audit_trail/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Anderson Freitas"]
6
- gem.email = ["gems@andersonfreitas.com"]
6
+ gem.email = ["me@andersonfreitas.com"]
7
7
  gem.description = %q{Simple audit trail for Rails models}
8
8
  gem.summary = gem.description
9
9
  gem.homepage = ""
@@ -1,4 +1,5 @@
1
1
  class AuditTrail < ActiveRecord::Base
2
2
  belongs_to :user
3
+ default_scope :order => "created_at desc"
3
4
  end
4
5
 
@@ -19,6 +19,7 @@ module HasAuditTrail
19
19
 
20
20
  self.audited_columns = opts[:only] || self.attribute_names.collect { |str| str.to_sym }
21
21
  self.audited_columns -= opts[:except] if opts[:except]
22
+ self.audited_columns -= [:id, :created_at, :updated_at]
22
23
 
23
24
  self.audited_associations = opts[:audit_nested] if opts[:audit_nested]
24
25
 
@@ -53,7 +54,9 @@ module HasAuditTrail
53
54
  end
54
55
 
55
56
  def audit_create
56
- write_audit(:action => :create)
57
+ self.audited_columns.each do |field|
58
+ write_audit(:action => :create, :new_value => self.send(field.to_sym).to_yaml, :property => field.to_sym)
59
+ end
57
60
  end
58
61
 
59
62
  def audit_destroy
@@ -1,3 +1,3 @@
1
1
  module HasAuditTrail
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_audit_trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-29 00:00:00.000000000 Z
12
+ date: 2012-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '3.0'
110
110
  description: Simple audit trail for Rails models
111
111
  email:
112
- - gems@andersonfreitas.com
112
+ - me@andersonfreitas.com
113
113
  executables: []
114
114
  extensions: []
115
115
  extra_rdoc_files: []