Diff
Modified: trunk/Rakefile (2420 => 2421)
--- trunk/Rakefile 2010-05-27 13:19:28 UTC (rev 2420)
+++ trunk/Rakefile 2010-06-02 14:11:51 UTC (rev 2421)
@@ -26,9 +26,11 @@
Contribution.find(:all).each do |c|
c.contributable.update_contribution_rank
c.contributable.update_contribution_rating
+ c.contributable.update_contribution_cache
ActiveRecord::Base.record_timestamps = false
+ c.reload
c.update_attribute(:created_at, c.contributable.created_at)
c.update_attribute(:updated_at, c.contributable.updated_at)
Modified: trunk/config/base_schema.xml (2420 => 2421)
--- trunk/config/base_schema.xml 2010-05-27 13:19:28 UTC (rev 2420)
+++ trunk/config/base_schema.xml 2010-06-02 14:11:51 UTC (rev 2421)
@@ -14,6 +14,9 @@
<column type="integer" name="viewings_count" default="0"/>
<column type="float" name="rating"/>
<column type="float" name="rank"/>
+ <column type="string" name="label"/>
+ <column type="integer" name="content_type_id"/>
+ <column type="integer" name="license_id"/>
<index>
<column name="contributable_id"/>
Modified: trunk/lib/acts_as_contributable.rb (2420 => 2421)
--- trunk/lib/acts_as_contributable.rb 2010-05-27 13:19:28 UTC (rev 2420)
+++ trunk/lib/acts_as_contributable.rb 2010-06-02 14:11:51 UTC (rev 2421)
@@ -21,6 +21,7 @@
after_save :save_contributable_record
after_save :update_contribution_rank
after_save :update_contribution_rating
+ after_save :update_contribution_cache
class_eval do
extend Mib::Acts::Contributable::SingletonMethods
@@ -88,7 +89,9 @@
value = 0.0
end
+ ActiveRecord::Base.record_timestamps = false
contribution.update_attribute(:rank, value)
+ ActiveRecord::Base.record_timestamps = true
end
end
@@ -101,9 +104,21 @@
value = 0.0
end
+ ActiveRecord::Base.record_timestamps = false
contribution.update_attribute(:rating, value)
+ ActiveRecord::Base.record_timestamps = true
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
+ end
+ end
end
end
end