diff --git a/app/models/closet_hanger.rb b/app/models/closet_hanger.rb index 7e2b4734..5a759fc8 100644 --- a/app/models/closet_hanger.rb +++ b/app/models/closet_hanger.rb @@ -12,9 +12,9 @@ class ClosetHanger < ApplicationRecord validate :list_belongs_to_user scope :alphabetical_by_item_name, -> { - joins(:item => :translations). - where(Item::Translation.arel_table[:locale].eq(I18n.locale)). - order(Item::Translation.arel_table[:name]) + it = Item::Translation.arel_table + joins(:item => :translations).where(it[:locale].eq(I18n.locale)). + order(it[:name].asc) } scope :newest, -> { order(arel_table[:created_at].desc) } scope :owned_before_wanted, -> { order(arel_table[:owned].desc) } diff --git a/app/models/color.rb b/app/models/color.rb index dc269d06..50b90822 100644 --- a/app/models/color.rb +++ b/app/models/color.rb @@ -1,7 +1,10 @@ class Color < ApplicationRecord translates :name - scope :alphabetical, -> { with_translations(I18n.locale).order(Color::Translation.arel_table[:name]) } + scope :alphabetical, -> { + ct = Color::Translation.arel_table + with_translations(I18n.locale).order(ct[:name].asc) + } scope :basic, -> { where(:basic => true) } scope :standard, -> { where(:standard => true) } scope :nonstandard, -> { where(:standard => false) } diff --git a/app/models/item.rb b/app/models/item.rb index 452788aa..e8e1879f 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -27,7 +27,7 @@ class Item < ApplicationRecord locale = locale or I18n.locale it = Item::Translation.arel_table joins(:translations).where(it[:locale].eq('en')). - order(it[:name]) + order(it[:name].asc) } scope :newest, -> { diff --git a/app/models/species.rb b/app/models/species.rb index 29e46311..8083dd22 100644 --- a/app/models/species.rb +++ b/app/models/species.rb @@ -1,7 +1,10 @@ class Species < ApplicationRecord translates :name - scope :alphabetical, -> { with_translations(I18n.locale).order(Species::Translation.arel_table[:name]) } + scope :alphabetical, -> { + st = Species::Translation.arel_table + with_translations(I18n.locale).order(st[:name].asc) + } scope :matching_name, ->(name, locale = I18n.locale) { st = Species::Translation.arel_table diff --git a/app/models/zone.rb b/app/models/zone.rb index 8ddc10c5..887fba03 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -1,4 +1,4 @@ -class Zone < ApplicationRecord +class Zone < ActiveRecord::Base translates :label, :plain_label # When selecting zones that an asset occupies, we allow the zone to set @@ -6,7 +6,8 @@ class Zone < ApplicationRecord attr_writer :sometimes scope :alphabetical, -> { - with_translations(I18n.locale).order(Zone::Translation.arel_table[:label]) + zt = Zone::Translation.arel_table + with_translations(I18n.locale).order(zt[:label].asc) } scope :includes_translations, -> { includes(:translations) } scope :matching_label, ->(label, locale = I18n.locale) {