From b9a10d554918ddeb03b99f2c9e84dd3ee9ef8618 Mon Sep 17 00:00:00 2001 From: Julien Portalier Date: Tue, 28 Nov 2023 09:23:19 +0100 Subject: [PATCH] Rails 5.0: params no longer inherit from Hash --- app/controllers/api/collections_controller.rb | 2 +- app/controllers/collections_controller.rb | 3 ++- app/controllers/sites_controller.rb | 2 +- plugins/fred_api/controllers/fred_api_controller.rb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/collections_controller.rb b/app/controllers/api/collections_controller.rb index 58ca4492..f92c0abb 100644 --- a/app/controllers/api/collections_controller.rb +++ b/app/controllers/api/collections_controller.rb @@ -181,7 +181,7 @@ def build_search(*options) except_params << :sort_direction end - search.where params.except(*except_params) + search.where params.except(*except_params).to_h search end diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index f893ce61..157365b3 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -211,7 +211,8 @@ def search search.hierarchy params[:hierarchy_code], params[:hierarchy_value] if params[:hierarchy_code] search.location_missing if params[:location_missing].present? search.name_search params[:sitename] if params[:sitename].present? - search.where params.except(:action, :controller, :format, :id, :collection_id, :updated_since, :search, :limit, :offset, :sort, :sort_direction, :hierarchy_code, :hierarchy_value, :location_missing, :locale, :sitename) + search.where params.except(:action, :controller, :format, :id, :collection_id, :updated_since, :search, :limit, :offset, :sort, :sort_direction, :hierarchy_code, :hierarchy_value, :location_missing, :locale, :sitename).to_h + results = search.results sites = results.map do |result| source = result['_source'] diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index c95d56f8..97b4227f 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -114,7 +114,7 @@ def search if params[:selected_hierarchy_id].present? search.selected_hierarchy params[:hierarchy_code], Field.find(params[:hierarchy_code]).descendants_of_in_hierarchy(params[:selected_hierarchy_id]) end - search.where params.except(:action, :controller, :format, :n, :s, :e, :w, :z, :collection_ids, :exclude_id, :updated_since, :search, :location_missing, :hierarchy_code, :selected_hierarchy_id, :locale, :sitename) + search.where params.except(:action, :controller, :format, :n, :s, :e, :w, :z, :collection_ids, :exclude_id, :updated_since, :search, :location_missing, :hierarchy_code, :selected_hierarchy_id, :locale, :sitename).to_h render_json search.results end diff --git a/plugins/fred_api/controllers/fred_api_controller.rb b/plugins/fred_api/controllers/fred_api_controller.rb index 2262bb96..064b6ab7 100644 --- a/plugins/fred_api/controllers/fred_api_controller.rb +++ b/plugins/fred_api/controllers/fred_api_controller.rb @@ -112,7 +112,7 @@ def facilities search.updated_since(params[:updatedSince]) if params[:updatedSince] # Query by Extended Properties - params_query = params.except(*except_params) + params_query = params.except(*except_params).to_h property_params = remove_prefix_form_properties_params(params_query) search.where property_params