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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user