From f34e65c207d81f7b1f9dbb9fe0c589978b8a1a7b Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Tue, 26 Feb 2019 19:17:33 +0100 Subject: [PATCH] [#3477] Make sanitized_column a class method --- app/models/procedure_presentation.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 6de06f9f1..e9e388590 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -94,7 +94,7 @@ class ProcedurePresentation < ApplicationRecord .pluck(:id) when 'self', 'user', 'individual', 'etablissement' return (table == 'self' ? dossiers : dossiers.includes(table)) - .order("#{sanitized_column(table, column)} #{order}") + .order("#{self.class.sanitized_column(table, column)} #{order}") .pluck(:id) end end @@ -103,7 +103,7 @@ class ProcedurePresentation < ApplicationRecord dossiers.each { |dossier| assert_matching_procedure(dossier) } filters[statut].group_by { |filter| filter.slice('table', 'column') } .map do |field, filters| table, column = field.values_at('table', 'column') - table_column = sanitized_column(table, column) + table_column = self.class.sanitized_column(table, column) values = filters.pluck('value') case table when 'self' @@ -268,7 +268,7 @@ class ProcedurePresentation < ApplicationRecord @column_whitelist[table] || [] end - def sanitized_column(table, column) + def self.sanitized_column(table, column) [(table == 'self' ? 'dossier' : table).pluralize, column] .map { |name| ActiveRecord::Base.connection.quote_column_name(name) } .join('.')