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:
committed by
Julian Herrero
parent
1a21b779ac
commit
596ef8d1ed
@@ -67,6 +67,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def poll_params
|
def poll_params
|
||||||
|
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||||
attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :results_enabled,
|
attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :results_enabled,
|
||||||
:stats_enabled, :budget_id, geozone_ids: [],
|
:stats_enabled, :budget_id, geozone_ids: [],
|
||||||
image_attributes: image_attributes]
|
image_attributes: image_attributes]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module Budgets
|
|||||||
.group_by(&:heading)
|
.group_by(&:heading)
|
||||||
else
|
else
|
||||||
@budget.investments.winners
|
@budget.investments.winners
|
||||||
.joins(:milestones).includes(:milestones)
|
.joins(milestones: :translations)
|
||||||
.distinct.group_by(&:heading)
|
.distinct.group_by(&:heading)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class PollsController < ApplicationController
|
|||||||
::Poll::Answer # trigger autoload
|
::Poll::Answer # trigger autoload
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@polls = @polls.not_budget.send(@current_filter).includes(:geozones).sort_for_list.page(params[:page])
|
@polls = @polls.not_budget.send(@current_filter).sort_for_list.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ class Budget
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.with_milestone_status_id(status_id)
|
def self.with_milestone_status_id(status_id)
|
||||||
joins(:milestones).includes(:milestones).select do |investment|
|
includes(milestones: :translations).select do |investment|
|
||||||
investment.milestone_status_id == status_id.to_i
|
investment.milestone_status_id == status_id.to_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Poll < ActiveRecord::Base
|
|||||||
scope :public_for_api, -> { all }
|
scope :public_for_api, -> { all }
|
||||||
scope :not_budget, -> { where(budget_id: nil) }
|
scope :not_budget, -> { where(budget_id: nil) }
|
||||||
|
|
||||||
scope :sort_for_list, -> { order(:geozone_restricted, :starts_at, :name) }
|
scope :sort_for_list, -> { joins(:translations).order(:geozone_restricted, :starts_at, "poll_translations.name") }
|
||||||
|
|
||||||
def title
|
def title
|
||||||
name
|
name
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Poll
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.available
|
def self.available
|
||||||
where(polls: { id: Poll.current_or_recounting }).includes(:polls)
|
where(polls: { id: Poll.current_or_recounting }).joins(polls: :translations)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assignment_on_poll(poll)
|
def assignment_on_poll(poll)
|
||||||
|
|||||||
Reference in New Issue
Block a user