aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/workbenches_controller.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb
index 1447c27de..b178a7fe2 100644
--- a/app/controllers/workbenches_controller.rb
+++ b/app/controllers/workbenches_controller.rb
@@ -11,8 +11,12 @@ class WorkbenchesController < BreadcrumbController
scope = ransack_status(scope)
# Ignore archived_at_not_null/archived_at_null managed by ransack_status scope
- q_for_result =
- scope.ransack(params[:q].merge(archived_at_not_null: nil, archived_at_null: nil))
+ # We clone params[:q] so we can delete fake ransack filter arguments before calling search method,
+ # which will allow us to preserve params[:q] for sorting
+ ransack_params = params[:q].merge(archived_at_not_null: nil, archived_at_null: nil).clone
+ ransack_params.delete('associated_lines_id_eq')
+
+ q_for_result = scope.ransack(ransack_params)
@wbench_refs = sort_result(q_for_result.result).paginate(page: params[:page], per_page: 30)
@wbench_refs = ModelDecorator.decorate(
@wbench_refs,
@@ -63,7 +67,6 @@ class WorkbenchesController < BreadcrumbController
def ransack_associated_lines scope
if params[:q] && params[:q]['associated_lines_id_eq']
scope = scope.include_metadatas_lines([params[:q]['associated_lines_id_eq']])
- params[:q].delete('associated_lines_id_eq')
end
scope
end