From 1e6bf953680bf03d4b797cf9b8f7235546b2c578 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 15 Mar 2024 23:14:43 +0100 Subject: Ensure that the last search is honored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- app/controllers/application_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fbe614c..80d4415 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,4 +19,15 @@ class ApplicationController < ActionController::Base def set_searches @searches = Search.order(:name) end + + # Redirect to the search that was last used by the current user. + def redirect_to_search! + search_id = current_user&.last_search_id + + if search_id + redirect_to search_path(search_id) + else + redirect_to root_url + end + end end -- cgit v1.2.3