From eb5e9d53cb39ff73f5284d78a6770a40338d8e81 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Aug 2023 17:57:53 -0700 Subject: [PATCH] Oops, fix anonymous outfits These are some old issues I just never tested for I think --- app/controllers/outfits_controller.rb | 2 +- app/models/outfit.rb | 2 +- app/models/pet_state.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/outfits_controller.rb b/app/controllers/outfits_controller.rb index d7eb61d2..7c41e21b 100644 --- a/app/controllers/outfits_controller.rb +++ b/app/controllers/outfits_controller.rb @@ -113,7 +113,7 @@ class OutfitsController < ApplicationController def outfit_params params.require(:outfit).permit( - :name, :pet_state_id, :starred, :worn_and_unworn_item_ids) + :name, :pet_state_id, :starred, :worn_and_unworn_item_ids, :anonymous) end def find_authorized_outfit diff --git a/app/models/outfit.rb b/app/models/outfit.rb index b04ae07d..2226e82a 100644 --- a/app/models/outfit.rb +++ b/app/models/outfit.rb @@ -4,7 +4,7 @@ class Outfit < ApplicationRecord :class_name => 'ItemOutfitRelationship' has_many :worn_items, :through => :worn_item_outfit_relationships, :source => :item belongs_to :pet_state - belongs_to :user + belongs_to :user, optional: true validates :name, :presence => {:if => :user_id}, :uniqueness => {:scope => :user_id, :if => :user_id} validates :pet_state, :presence => true diff --git a/app/models/pet_state.rb b/app/models/pet_state.rb index 24b6202e..867de11e 100644 --- a/app/models/pet_state.rb +++ b/app/models/pet_state.rb @@ -38,7 +38,7 @@ class PetState < ApplicationRecord joins(:parent_swf_asset_relationships). 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("glitched ASC, (mood_id = 1) DESC, COUNT(effect_assets.remote_id) ASC, COUNT(parents_swf_assets.swf_asset_id) DESC, female ASC, SUM(parents_swf_assets.swf_asset_id) ASC") + order(Arel.sql("glitched ASC, (mood_id = 1) DESC, COUNT(effect_assets.remote_id) ASC, COUNT(parents_swf_assets.swf_asset_id) DESC, female ASC, SUM(parents_swf_assets.swf_asset_id) ASC")) } def as_json(options={})