From 7795119a8cc71508ff89569bec042c852f86d98b Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 15 Mar 2012 17:01:21 -0500 Subject: [PATCH] fix gender/emotion states with corridor of chance effects sorting to the front So it turns out this was just one of those things I forgot to fix the big database restructure came along: we were comparing swf_asset.remote_id against parents_swf_assets.swf_asset_id, which are two different identifiers entirely. Now using swf_asset.id, so fixed :) --- app/models/pet_state.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/pet_state.rb b/app/models/pet_state.rb index 63cf8998..39e549ab 100644 --- a/app/models/pet_state.rb +++ b/app/models/pet_state.rb @@ -15,7 +15,7 @@ class PetState < ActiveRecord::Base bio_effect_zone_id = 4 scope :emotion_order, joins(:parent_swf_asset_relationships). - joins("LEFT JOIN swf_assets effect_assets ON effect_assets.remote_id = parents_swf_assets.swf_asset_id AND effect_assets.zone_id = #{bio_effect_zone_id}"). + joins("LEFT JOIN swf_assets effect_assets ON effect_assets.id = parents_swf_assets.swf_asset_id AND effect_assets.zone_id = #{bio_effect_zone_id}"). group("pet_states.id"). order("COUNT(effect_assets.remote_id) ASC, COUNT(parents_swf_assets.swf_asset_id) DESC, SUM(parents_swf_assets.swf_asset_id) ASC")