Order translations using ruby
Joining the translations table caused duplicate records to appear. Ordering with SQL is simply too hard because we need to consider fallback locales. Thanks Senén for providing most of the tests in the poll spec.
This commit is contained in:
@@ -12,8 +12,9 @@ class PollsController < ApplicationController
|
||||
::Poll::Answer # trigger autoload
|
||||
|
||||
def index
|
||||
@polls = @polls.not_budget.public_polls.send(@current_filter).includes(:geozones)
|
||||
.sort_for_list.page(params[:page])
|
||||
@polls = Kaminari.paginate_array(
|
||||
@polls.public_polls.not_budget.send(@current_filter).includes(:geozones).sort_for_list
|
||||
).page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -75,9 +75,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
def heading_filters
|
||||
investments = @budget.investments.by_valuator(current_user.valuator.try(:id))
|
||||
.visible_to_valuators.distinct
|
||||
investment_headings = Budget::Heading.joins(:translations)
|
||||
.where(id: investments.pluck(:heading_id).uniq)
|
||||
.order(name: :asc)
|
||||
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id)).sort_by(&:name)
|
||||
|
||||
all_headings_filter = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user