From 698420199041057b5cab06447315bbe10a14ecd3 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 26 Jun 2013 20:08:19 -0700 Subject: [PATCH] dev util method to manually change SWF asset body ID --- app/models/swf_asset.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/swf_asset.rb b/app/models/swf_asset.rb index 5dfdeed2..1fb2d8f4 100644 --- a/app/models/swf_asset.rb +++ b/app/models/swf_asset.rb @@ -176,6 +176,13 @@ class SwfAsset < ActiveRecord::Base select('swf_assets.*, parents_swf_assets.parent_id') } + # To manually change the body ID without triggering the usual change to 0, + # use this override method. + def override_body_id(new_body_id) + @body_id_overridden = true + self.body_id = new_body_id + end + def local_url '/' + File.join(PUBLIC_ASSET_DIR, local_path_within_outfit_swfs) end @@ -259,7 +266,7 @@ class SwfAsset < ActiveRecord::Base before_save do # 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_specific? || (!self.new_record? && self.body_id_changed?) + self.body_id = 0 if !@body_id_overridden && (!self.body_specific? || (!self.new_record? && self.body_id_changed?)) end after_commit :on => :create do