diff options
| author | Xinhui | 2017-06-28 17:20:23 +0200 |
|---|---|---|
| committer | Xinhui | 2017-06-28 17:20:23 +0200 |
| commit | bed9795be0bb85d7c8c311fe4ee0fb12e46832b4 (patch) | |
| tree | 18459aa9dcb81821a88f2acdf9ba72cee9be5616 /app/controllers/workbenches_controller.rb | |
| parent | 641b1458236d2718a76ffaf0c04a5998623276bf (diff) | |
| parent | b260c832c8e129dbeacfe065d01bd0732dd80701 (diff) | |
| download | chouette-core-bed9795be0bb85d7c8c311fe4ee0fb12e46832b4.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'app/controllers/workbenches_controller.rb')
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index ccd55965b..d03841356 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -11,11 +11,18 @@ 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)) - @wbench_refs = sort_result(q_for_result.result).paginate(page: params[:page], per_page: 30) + # 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 = scope.ransack(ransack_params) + @wbench_refs = sort_result(@q.result).paginate(page: params[:page], per_page: 30) + @wbench_refs = ModelDecorator.decorate( + @wbench_refs, + with: ReferentialDecorator + ) - @q = scope.ransack(params[:q]) show! do build_breadcrumb :show end @@ -33,7 +40,7 @@ class WorkbenchesController < BreadcrumbController private def resource - @workbench = Workbench.find params[:id] + @workbench = current_organisation.workbenches.find params[:id] end def sort_result collection @@ -59,7 +66,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 |
