From f8662c9184fd3f4041c1ff514ddc1f674ee59aa7 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Thu, 10 Aug 2017 23:34:56 +0200 Subject: [PATCH] Redirect to root_url of default_scope when no slug is given --- app/controllers/application_controller.rb | 3 ++- lib/foodsoft_config.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8323da7d..054e3a56 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -172,10 +172,11 @@ class ApplicationController < ActionController::Base # Set Config and database connection FoodsoftConfig.select_foodcoop params[:foodcoop] rescue => error - FoodsoftConfig.select_foodcoop FoodsoftConfig.config[:default_scope] + FoodsoftConfig.select_default_foodcoop redirect_to root_url, alert: error.message end else + FoodsoftConfig.select_default_foodcoop redirect_to root_url end end diff --git a/lib/foodsoft_config.rb b/lib/foodsoft_config.rb index a89784ac..890aea85 100644 --- a/lib/foodsoft_config.rb +++ b/lib/foodsoft_config.rb @@ -80,6 +80,10 @@ class FoodsoftConfig setup_database end + def select_default_foodcoop + select_foodcoop config[:default_scope] + end + def select_multifoodcoop(foodcoop) select_foodcoop foodcoop if config[:multi_coop_install] end