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
This commit is contained in:
Emi Matchu 2010-11-15 17:56:16 -05:00
parent 9fc24a2eab
commit 8e6a34b69c
3 changed files with 1 additions and 3 deletions

View file

@ -49,7 +49,6 @@ class Pet < ActiveRecord::Base
def contributables def contributables
contributables = [pet_type, @pet_state] contributables = [pet_type, @pet_state]
items.each do |item| items.each do |item|
item.handle_assets!
contributables << item contributables << item
contributables += item.pending_swf_assets contributables += item.pending_swf_assets
end end

View file

@ -97,7 +97,6 @@ class PetType < ActiveRecord::Base
def add_pet_state_from_biology!(biology) def add_pet_state_from_biology!(biology)
pet_state = PetState.from_pet_type_and_biology_info(self, biology) pet_state = PetState.from_pet_type_and_biology_info(self, biology)
self.pet_states << pet_state
pet_state pet_state
end end

View file

@ -17,10 +17,10 @@ class User < ActiveRecord::Base
new_points += contribution.point_value new_points += contribution.point_value
end end
end end
self.contributions += new_contributions
self.points += new_points self.points += new_points
Pet.transaction do Pet.transaction do
pet.save! pet.save!
self.contributions += new_contributions
save! save!
end end
new_points new_points