From 166f907780a1f69a9b9e2d848c54adbd1f1e67dc Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 2 Aug 2016 11:10:30 +0200 Subject: [PATCH] fixed search error --- app/controllers/search_controller.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index f67c88328..b1f18c518 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -55,15 +55,18 @@ class SearchController < ApplicationController flash[:error] = t'search.index.error.query_length', n: MIN_QUERY_CHARS redirect_to :back else - @splited_query.each_with_index do |w, i| - if @splited_query.length > 1 && w.length < MIN_QUERY_CHARS - @splited_query.slice!(i) + if @splited_query.length > 1 + @search_query = '' + @splited_query.each_with_index do |w, i| + if w.length >= MIN_QUERY_CHARS + @search_query += "#{@splited_query[i]} " + end end + else + @search_query = @splited_query.join(' ') end end - @search_query = @splited_query.join(' ') - if @search_page < 1 @search_page = 1 end