From 3eee2633bd93d820df4a6f40734bd0c7aa60c173 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 9 Oct 2010 11:23:59 -0400 Subject: [PATCH] set body id to 0 when appropriate --- app/models/swf_asset.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 77267581..e5a8f3d3 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -28,8 +28,12 @@ class SwfAsset < ActiveRecord::Base } end + def body_specific? + self.body_id == 0 || self.zone.type_id < 3 + end + def zone - @zone ||= Zone.find(zone_id) + Zone.find(zone_id) end def origin_pet_type=(pet_type) @@ -71,6 +75,12 @@ class SwfAsset < ActiveRecord::Base end end + def before_save + # If an asset body ID changes, that means more than one body ID has been + # linked to it, meaning that it's probably wearable by all bodies. + self.body_id = 0 if self.body_id_changed? || !self.body_specific? + end + private def local_path_within_outfit_swfs