From 38d79468bd36b665b676dbfcaea7ff12d71538f5 Mon Sep 17 00:00:00 2001 From: Christian Sutter Date: Mon, 20 Nov 2023 15:27:24 +0000 Subject: [PATCH] Don't show results for empty query --- app/models/search.rb | 4 ++++ app/views/searches/show.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/search.rb b/app/models/search.rb index 582a864..8edd14d 100644 --- a/app/models/search.rb +++ b/app/models/search.rb @@ -5,6 +5,10 @@ class Search attr_accessor :query, :search_options + def show_results? + query.present? + end + def results response["results"].map do |result| timestamp = Time.zone.parse(result["public_timestamp"]) diff --git a/app/views/searches/show.html.erb b/app/views/searches/show.html.erb index b0cfc4f..be8076a 100644 --- a/app/views/searches/show.html.erb +++ b/app/views/searches/show.html.erb @@ -45,7 +45,7 @@ } %> -<% else %> +<% elsif @search.show_results? %>