Diff
Modified: trunk/app/models/pack_contributable_entry.rb (2704 => 2705)
--- trunk/app/models/pack_contributable_entry.rb 2011-09-16 12:34:59 UTC (rev 2704)
+++ trunk/app/models/pack_contributable_entry.rb 2011-09-16 15:34:40 UTC (rev 2705)
@@ -75,6 +75,7 @@
end
def touch_pack
- pack.touch
+ # Rails 2 - use pack.destroyed? instead of pack.contribution.nil?
+ pack.touch unless pack.contribution.nil?
end
end
Modified: trunk/app/models/pack_remote_entry.rb (2704 => 2705)
--- trunk/app/models/pack_remote_entry.rb 2011-09-16 12:34:59 UTC (rev 2704)
+++ trunk/app/models/pack_remote_entry.rb 2011-09-16 15:34:40 UTC (rev 2705)
@@ -28,6 +28,7 @@
end
def touch_pack
- pack.touch
+ # Rails 2 - use pack.destroyed? instead of pack.contribution.nil?
+ pack.touch unless pack.contribution.nil?
end
end
Modified: trunk/app/models/relationship.rb (2704 => 2705)
--- trunk/app/models/relationship.rb 2011-09-16 12:34:59 UTC (rev 2704)
+++ trunk/app/models/relationship.rb 2011-09-16 15:34:40 UTC (rev 2705)
@@ -13,7 +13,8 @@
after_destroy :touch_context
def touch_context
- context.touch if context.respond_to?(:touch)
+ # Rails 2 - use context.destroyed? instead of context.contribution.nil?
+ context.touch if !context.contribution.nil? && context.respond_to?(:touch)
end
end
Modified: trunk/config/environment.rb (2704 => 2705)
--- trunk/config/environment.rb 2011-09-16 12:34:59 UTC (rev 2704)
+++ trunk/config/environment.rb 2011-09-16 15:34:40 UTC (rev 2705)
@@ -92,5 +92,23 @@
end
end
+class ActiveRecord::Base
+
+ def inhibit_timestamps(&blk)
+
+ initial_value = ActiveRecord::Base.record_timestamps
+
+ begin
+ ActiveRecord::Base.record_timestamps = false
+ yield
+ rescue Exception
+ ActiveRecord::Base.record_timestamps = initial_value
+ raise
+ end
+
+ ActiveRecord::Base.record_timestamps = initial_value
+ end
+end
+
load 'config/environment_private.rb' if FileTest.exist?('config/environment_private.rb')
Modified: trunk/lib/acts_as_contributable.rb (2704 => 2705)
--- trunk/lib/acts_as_contributable.rb 2011-09-16 12:34:59 UTC (rev 2704)
+++ trunk/lib/acts_as_contributable.rb 2011-09-16 15:34:40 UTC (rev 2705)
@@ -76,7 +76,9 @@
# contributable
def save_contributable_record
if contribution
- contribution.save
+ inhibit_timestamps do
+ contribution.update_attribute(:updated_at, contribution.contributable.updated_at)
+ end
end
end
@@ -89,9 +91,9 @@
value = 0.0
end
- ActiveRecord::Base.record_timestamps = false
- contribution.update_attribute(:rank, value)
- ActiveRecord::Base.record_timestamps = true
+ inhibit_timestamps do
+ contribution.update_attribute(:rank, value)
+ end
end
end
@@ -104,19 +106,19 @@
value = 0.0
end
- ActiveRecord::Base.record_timestamps = false
- contribution.update_attribute(:rating, value)
- ActiveRecord::Base.record_timestamps = true
+ inhibit_timestamps do
+ contribution.update_attribute(:rating, value)
+ end
end
end
def update_contribution_cache
if contribution
- ActiveRecord::Base.record_timestamps = false
- contribution.update_attribute(:label, respond_to?(:label) ? label : nil)
- contribution.update_attribute(:content_type_id, respond_to?(:content_type_id) ? content_type_id : nil)
- contribution.update_attribute(:license_id, respond_to?(:license_id) ? license_id : nil)
- ActiveRecord::Base.record_timestamps = true
+ inhibit_timestamps do
+ contribution.update_attribute(:label, respond_to?(:label) ? label : nil)
+ contribution.update_attribute(:content_type_id, respond_to?(:content_type_id) ? content_type_id : nil)
+ contribution.update_attribute(:license_id, respond_to?(:license_id) ? license_id : nil)
+ end
end
end
end