Redirect to root_url of default_scope when no slug is given

This commit is contained in:
Patrick Gansterer 2017-08-10 23:34:56 +02:00
parent 6185e18cc5
commit f8662c9184
2 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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