diff --git a/lib/librarix/helpers.rb b/lib/librarix/helpers.rb index e13e285..972ad43 100644 --- a/lib/librarix/helpers.rb +++ b/lib/librarix/helpers.rb @@ -7,5 +7,9 @@ module Librarix 'default' end end + + def maybe_search?(movies) + movies.empty? && params.key?('title') + end end end diff --git a/lib/librarix/views/index.slim b/lib/librarix/views/index.slim index c3a524f..91471b7 100644 --- a/lib/librarix/views/index.slim +++ b/lib/librarix/views/index.slim @@ -17,3 +17,9 @@ form method="get" action="/" id="filter" == slim :list, locals: {movies: movies} +- if maybe_search?(movies) + p + | Search for + strong + a<> href="#{url("/search?search=#{params['title']}")}" = params['title'] + | ?