From 46076bf6127efea667cc764dd2fc4a9d66451c9f Mon Sep 17 00:00:00 2001 From: vlatka pavisic Date: Thu, 17 Nov 2016 17:51:27 +0100 Subject: Refs #1939 : Refactor --- app/controllers/lines_controller.rb | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index bd1550a00..925ac54bf 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -73,20 +73,11 @@ class LinesController < BreadcrumbController end def collection - if params[:q] && params[:q]["network_id_eq"] == "-1" - params[:q]["network_id_eq"] = "" - params[:q]["network_id_blank"] = "1" - end - - if params[:q] && params[:q]["company_id_eq"] == "-1" - params[:q]["company_id_eq"] = "" - params[:q]["company_id_blank"] = "1" - end - - if params[:q] && params[:q]["group_of_lines_id_eq"] == "-1" - params[:q]["group_of_lines_id_eq"] = "" - params[:q]["group_of_lines_id_blank"] = "1" - end + %w(network_id company_id group_of_lines_id comment_id transport_mode_name).each do |filter| + if params[:q] && params[:q]["#{filter}_eq"] == '-1' + params[:q]["#{filter}_eq"] = '' + params[:q]["#{filter}_blank"] = '1' + end @q = line_referential.lines.search(params[:q]) @lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page]).includes([:network, :company]) -- cgit v1.2.3