From 8e6a34b69c010f76126c086db2555f66ebdb721f Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 15 Nov 2010 17:56:16 -0500 Subject: [PATCH] fix contributions for pet states and items dependent contributables would only count as contributed if their parent was being contributed for the first time, too. the trick was to delay actually *assigning* them to their parents until the very, very end --- app/models/pet.rb | 1 - app/models/pet_type.rb | 1 - app/models/user.rb | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/pet.rb b/app/models/pet.rb index 390a58b9..08b40519 100644 --- a/app/models/pet.rb +++ b/app/models/pet.rb @@ -49,7 +49,6 @@ class Pet < ActiveRecord::Base def contributables contributables = [pet_type, @pet_state] items.each do |item| - item.handle_assets! contributables << item contributables += item.pending_swf_assets end diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index ee5c30c4..15ea85d2 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -97,7 +97,6 @@ class PetType < ActiveRecord::Base def add_pet_state_from_biology!(biology) pet_state = PetState.from_pet_type_and_biology_info(self, biology) - self.pet_states << pet_state pet_state end diff --git a/app/models/user.rb b/app/models/user.rb index 22bf36ec..4a7dd4c7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,10 +17,10 @@ class User < ActiveRecord::Base new_points += contribution.point_value end end - self.contributions += new_contributions self.points += new_points Pet.transaction do pet.save! + self.contributions += new_contributions save! end new_points