sort effects to the end of the gender/emotion list

This commit is contained in:
Emi Matchu 2011-06-21 20:42:41 -04:00
parent 74482dbf75
commit 99a23fc2cb
2 changed files with 17 additions and 15 deletions

View file

@ -12,8 +12,9 @@ class PetState < ActiveRecord::Base
alias_method :swf_asset_ids_from_association, :swf_asset_ids alias_method :swf_asset_ids_from_association, :swf_asset_ids
scope :emotion_order, joins(:parent_swf_asset_relationships). bio_effect_zone_id = 4
group("pet_states.id").order("COUNT(parents_swf_assets.swf_asset_id) DESC, SUM(parents_swf_assets.swf_asset_id) ASC") scope :emotion_order, joins(:parent_swf_asset_relationships => :biology_asset).
group("pet_states.id").order("COUNT(swf_assets.zone_id = #{bio_effect_zone_id}) ASC, COUNT(parents_swf_assets.swf_asset_id) DESC, SUM(parents_swf_assets.swf_asset_id) ASC")
def reassign_children_to!(main_pet_state) def reassign_children_to!(main_pet_state)
self.contributions.each do |contribution| self.contributions.each do |contribution|
@ -124,3 +125,4 @@ class PetState < ActiveRecord::Base
end end
end end
end end

View file

@ -35,7 +35,7 @@ class PetType < ActiveRecord::Base
def as_json(options={}) def as_json(options={})
if options[:for] == 'wardrobe' if options[:for] == 'wardrobe'
{:id => id, :body_id => body_id, :pet_state_ids => pet_states.select([:id]).emotion_order.map(&:id)} {:id => id, :body_id => body_id, :pet_state_ids => pet_states.select('pet_states.id').emotion_order.map(&:id)}
else else
{:image_hash => image_hash} {:image_hash => image_hash}
end end