From b0d2eda3516d33a2d671b9b6935f448b087ed52a Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 30 Nov 2017 08:05:00 +0100 Subject: [PATCH] handle invalid query less absolute --- app/controllers/projects_controller.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c709656982..f55c1714cc 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -59,13 +59,12 @@ class ProjectsController < ApplicationController query = load_query set_sorting(query) - if query.valid? - @projects = load_projects query - @custom_fields = ProjectCustomField.visible(User.current) - else + unless query.valid? flash[:error] = query.errors.full_messages - redirect_back(fallback_location: projects_path) end + + @projects = load_projects query + @custom_fields = ProjectCustomField.visible(User.current) end current_menu_item :index do @@ -326,7 +325,7 @@ class ProjectsController < ApplicationController end def set_sorting(query) - orders = query.orders.map { |o| [o.attribute.to_s, o.direction.to_s] } + orders = query.orders.select(&:valid?).map { |o| [o.attribute.to_s, o.direction.to_s] } sort_clear sort_init orders