kb-acts_as_revisable 1.0.3 → 1.0.4
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.
@@ -329,13 +329,7 @@ module WithoutScope
|
|
329
329
|
self.revisable_revision = nil
|
330
330
|
return true
|
331
331
|
elsif self.revisable_revision
|
332
|
-
|
333
|
-
self.class.revision_class.without_stamps do
|
334
|
-
self.revisable_revision.save
|
335
|
-
end
|
336
|
-
else
|
337
|
-
self.revisable_revision.save
|
338
|
-
end
|
332
|
+
self.revisable_revision.save
|
339
333
|
revisions.reload
|
340
334
|
run_callbacks(:after_revise)
|
341
335
|
end
|
@@ -29,7 +29,15 @@ module WithoutScope
|
|
29
29
|
[:current_revision, revisable_association_name.to_sym].each do |a|
|
30
30
|
belongs_to a, :class_name => revisable_class_name, :foreign_key => :revisable_original_id
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
|
+
# add an author association if there is such a class
|
34
|
+
begin
|
35
|
+
if User.is_a?(Class) && User.respond_to?('current_user')
|
36
|
+
belongs_to :author, :class_name => 'User', :foreign_key => 'revisable_author_id'
|
37
|
+
end
|
38
|
+
rescue NameError
|
39
|
+
end
|
40
|
+
|
33
41
|
[[:ancestors, "<"], [:descendants, ">"]].each do |a|
|
34
42
|
# Jumping through hoops here to try and make sure the
|
35
43
|
# :finder_sql is cross-database compatible. :finder_sql
|
@@ -70,6 +78,7 @@ module WithoutScope
|
|
70
78
|
prev.update_attribute(:revisable_revised_at, now) if prev
|
71
79
|
self[:revisable_current_at] = now + 1.second
|
72
80
|
self[:revisable_is_current] = false
|
81
|
+
self[:revisable_author_id] = (User.current_user.id rescue nil)
|
73
82
|
self[:revisable_branched_from_id] = current_revision[:revisable_branched_from_id]
|
74
83
|
self[:revisable_type] = current_revision[:type]
|
75
84
|
self[:revisable_number] = (self.class.maximum(:revisable_number, :conditions => {:revisable_original_id => self[:revisable_original_id]}) || 0) + 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kb-acts_as_revisable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Cavanaugh
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- rails/init.rb
|
57
57
|
has_rdoc: true
|
58
58
|
homepage: http://github.com/rich/acts_as_revisable
|
59
|
+
licenses:
|
59
60
|
post_install_message:
|
60
61
|
rdoc_options:
|
61
62
|
- --main
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
requirements: []
|
78
79
|
|
79
80
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.3.5
|
81
82
|
signing_key:
|
82
83
|
specification_version: 2
|
83
84
|
summary: acts_as_revisable enables revision tracking, querying, reverting and branching of ActiveRecord models. Inspired by acts_as_versioned.
|