diff --git a/app/models/pet.rb b/app/models/pet.rb index 35454d1e..be151a9c 100644 --- a/app/models/pet.rb +++ b/app/models/pet.rb @@ -65,7 +65,11 @@ class Pet < ActiveRecord::Base before_validation do pet_type.save! - @pet_state.save! if @pet_state + if @pet_state + @pet_state.handle_assets! + @pet_state.save! + end + if @items @items.each do |item| item.handle_assets! diff --git a/app/models/pet_state.rb b/app/models/pet_state.rb index 5f605708..a95a5c40 100644 --- a/app/models/pet_state.rb +++ b/app/models/pet_state.rb @@ -53,6 +53,12 @@ class PetState < ActiveRecord::Base def swf_asset_ids=(ids) self['swf_asset_ids'] = ids end + + def handle_assets! + parent_swf_asset_relationships.each do |rel| + rel.swf_asset.save! + end + end def self.from_pet_type_and_biology_info(pet_type, info) swf_asset_ids = []