From c2d38720ad3c40866aade122c1bfbc0d14b1a666 Mon Sep 17 00:00:00 2001 From: Toks Date: Fri, 29 Nov 2013 16:15:41 -0500 Subject: [PATCH] Trim down unnecessarily long query strings When submitting search forms, fields that aren't filled out will still appear in the url, taking up space and making the url harder to understand. This commit removes blank parameters from the query string and redirects to the new url. Since these blank parameters were already ignored by the individual #search methods this shouldn't negatively affect anything. --- app/controllers/application_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 691f04cc5..4ffb9d222 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -103,6 +103,10 @@ protected def normalize_search if request.get? params[:search] ||= {} + changed = params[:search].reject! {|k,v| v.blank?} + unless changed.nil? + redirect_to params + end end end