Fix search without querry

App crash when we try to get /search

Add an empty querry '' as default
This commit is contained in:
GROUX Richard
2015-07-21 19:35:45 +02:00
parent 596afe9451
commit f9e5c05046
+1 -1
View File
@@ -438,7 +438,7 @@ module Precious
end
get '/search' do
@query = params[:q]
@query = params[:q] || ''
wiki = wiki_new
# Sort wiki search results by count (desc) and then by name (asc)
@results = wiki.search(@query).sort { |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse