Skip to content

Commit

Permalink
Database collation differ in production
Browse files Browse the repository at this point in the history
  • Loading branch information
Calyhre committed May 20, 2017
1 parent e18219e commit 01485a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/models/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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

0 comments on commit 01485a0

Please sign in to comment.