Fix queries and scopes after column deletion

Some queries were accessing original column instead of the new translatable one. This should have been causing unexpected behavior for requests maded in a different locale than the application default.
This commit is contained in:
taitus
2019-03-26 12:51:23 +01:00
committed by Julian Herrero
parent fbfe5b3468
commit 638c80760f
2 changed files with 2 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ class Budget
validates :budget_id, presence: true
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
scope :sort_by_name, -> { includes(:translations).order(:name) }
scope :sort_by_name, -> { joins(:translations).order(:name) }
def single_heading_group?
headings.count == 1

View File

@@ -128,7 +128,7 @@ class User < ActiveRecord::Base
end
def headings_voted_within_group(group)
Budget::Heading.order("name").where(id: voted_investments.by_group(group).pluck(:heading_id))
Budget::Heading.joins(:translations).order("name").where(id: voted_investments.by_group(group).pluck(:heading_id))
end
def voted_investments