Skip to content

Commit

Permalink
Rails 5.0: params no longer inherit from Hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Nov 28, 2023
1 parent c110e34 commit b9a10d5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion plugins/fred_api/controllers/fred_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b9a10d5

Please sign in to comment.