From b6c21dfe40e535f6fc0187ffd7b14e63b9a6e05e Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Fri, 15 Nov 2024 20:28:38 -0800 Subject: [PATCH] Oops, fix sort order for alt styles Oh huh, when doing Rainbow Pool stuff, I put the ordering in the wrong place! It's a sensible ordering for the Rainbow Pool page, but not so much for the JSON view! --- app/controllers/alt_styles_controller.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controllers/alt_styles_controller.rb b/app/controllers/alt_styles_controller.rb index 7f51d7a6..742034d7 100644 --- a/app/controllers/alt_styles_controller.rb +++ b/app/controllers/alt_styles_controller.rb @@ -15,9 +15,7 @@ class AltStylesController < ApplicationController @color = find_color @species = find_species - @alt_styles = @all_alt_styles.includes(:swf_assets). - by_creation_date.order(:color_id, :species_id, :series_name). - paginate(page: params[:page], per_page: 30) + @alt_styles = @all_alt_styles.includes(:swf_assets) @alt_styles.where!(series_name: @series_name) if @series_name.present? @alt_styles.merge!(@color.alt_styles) if @color @alt_styles.merge!(@species.alt_styles) if @species @@ -27,9 +25,16 @@ class AltStylesController < ApplicationController SwfAsset.preload_manifests @alt_styles.map(&:swf_assets).flatten respond_to do |format| - format.html { render } + format.html { + @alt_styles = @alt_styles. + by_creation_date.order(:color_id, :species_id, :series_name). + paginate(page: params[:page], per_page: 30) + render + } format.json { - render json: @alt_styles.includes(swf_assets: [:zone]).as_json( + @alt_styles = @alt_styles.includes(swf_assets: [:zone]). + sort_by(&:full_name) + render json: @alt_styles.as_json( only: [:id, :species_id, :color_id, :body_id, :series_name, :adjective_name, :thumbnail_url], include: {