From cc23f7435b2026758a4c526d57c785da159b85ab Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 31 Oct 2011 16:22:24 -0500 Subject: [PATCH] automatically rezone bio --- app/models/pet.rb | 6 +++++- app/models/pet_state.rb | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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 = []