From eaf875c6c7f89f2de36179f20a5d9b3d5ae46bde Mon Sep 17 00:00:00 2001 From: Matchu Date: Sun, 27 Jan 2013 00:25:52 -0600 Subject: [PATCH] zone, species, color alphabetical by the current locale We were joining to the translations table to sort records alphabetically, but then it sorted by *all* of the translations in some strange way. Now use with_translations to restrict the join to the current locale. --- app/models/color.rb | 2 +- app/models/species.rb | 2 +- app/models/zone.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/color.rb b/app/models/color.rb index 792dc21b..c73cd9b5 100644 --- a/app/models/color.rb +++ b/app/models/color.rb @@ -1,7 +1,7 @@ class Color < ActiveRecord::Base translates :name - scope :alphabetical, lambda { includes(:translations).order(Color::Translation.arel_table[:name]) } + scope :alphabetical, lambda { with_translations(I18n.locale).order(Color::Translation.arel_table[:name]) } scope :basic, where(:basic => true) scope :standard, where(:standard => true) scope :nonstandard, where(:standard => false) diff --git a/app/models/species.rb b/app/models/species.rb index ac3b4f4e..71922dc7 100644 --- a/app/models/species.rb +++ b/app/models/species.rb @@ -1,7 +1,7 @@ class Species < ActiveRecord::Base translates :name - scope :alphabetical, lambda { includes(:translations).order(Species::Translation.arel_table[:name]) } + scope :alphabetical, lambda { with_translations(I18n.locale).order(Species::Translation.arel_table[:name]) } def as_json(options={}) {:id => id, :name => human_name} diff --git a/app/models/zone.rb b/app/models/zone.rb index 83ec6c2e..c149156c 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -6,7 +6,7 @@ class Zone < ActiveRecord::Base attr_writer :sometimes scope :alphabetical, lambda { - includes_translations.order(Zone::Translation.arel_table[:label]) + with_translations(I18n.locale).order(Zone::Translation.arel_table[:label]) } scope :includes_translations, lambda { includes(:translations) } scope :with_plain_label, lambda { |label|