From 01485a02fafbf4eae457542928238595224a08b5 Mon Sep 17 00:00:00 2001 From: Charley DAVID Date: Sat, 20 May 2017 20:20:22 -0300 Subject: [PATCH] Database collation differ in production --- app/models/game.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/game.rb b/app/models/game.rb index 86b05fb..595b2f8 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -17,6 +17,10 @@ class Game < ApplicationRecord has_many :prices + scope :order_by_title, -> { + order('LOWER(title COLLATE "C")') + } + scope :order_by_region, -> { order_by = ['case'] REGIONS.each_with_index do |region, index| @@ -26,6 +30,6 @@ class Game < ApplicationRecord order(order_by.join(' ')) } - scope :by_game_code, -> { order_by_region.order('LOWER(title)').group_by(&:game_code) } - scope :by_region, -> { order_by_region.order('LOWER(title)').group_by(&:region) } + scope :by_game_code, -> { order_by_title.order_by_region.group_by(&:game_code) } + scope :by_region, -> { order_by_title.order_by_region.group_by(&:region) } end