diff --git a/MULTI_COOP_INSTALL b/MULTI_COOP_INSTALL new file mode 100644 index 00000000..602306c4 --- /dev/null +++ b/MULTI_COOP_INSTALL @@ -0,0 +1 @@ +TODO.. \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 674976b5..64160b21 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,8 +1,6 @@ class ApplicationController < ActionController::Base - # If you wanna run multiple foodcoops on one installation uncomment next line. - #before_filter :select_foodcoop - before_filter :authenticate, :store_controller + before_filter :select_foodcoop, :authenticate, :store_controller after_filter :remove_controller # sends a mail, when an error occurs @@ -140,11 +138,13 @@ class ApplicationController < ActionController::Base # It uses the subdomain to select the appropriate section in the config files # Use this method as a before filter (first filter!) in ApplicationController def select_foodcoop - # Get subdomain - subdomain = request.subdomains.first - # Set Config - Foodsoft.env = subdomain - # Set database-connection - ActiveRecord::Base.establish_connection(Foodsoft.database(subdomain)) + if Foodsoft.config[:multi_coop_install] + # Get subdomain + subdomain = request.subdomains.first + # Set Config + Foodsoft.env = subdomain + # Set database-connection + ActiveRecord::Base.establish_connection(Foodsoft.database(subdomain)) + end end end diff --git a/config/app_config.yml.SAMPLE b/config/app_config.yml.SAMPLE index b0d4b70f..911c43f1 100644 --- a/config/app_config.yml.SAMPLE +++ b/config/app_config.yml.SAMPLE @@ -1,6 +1,10 @@ # Foodsoft configuration development: &defaults + # If you wanna serve more than one foodcoop with one installation + # Don't forget to setup databases for each foodcoop. See also MULTI_COOP_INSTALL + multi_coop_install: false + # name of this foodcoop name: FC Test # foodcoop contact information (used for FAX messages) diff --git a/config/initializers/load_app_config.rb b/config/initializers/load_app_config.rb index 904ce9cb..e0ff3ff7 100644 --- a/config/initializers/load_app_config.rb +++ b/config/initializers/load_app_config.rb @@ -13,10 +13,12 @@ module Foodsoft end def config(rails_env = @@env) + raise "No config for this environment (or subdomain) available!" if @@configs[rails_env].nil? @@configs[rails_env].symbolize_keys end def database(rails_env = @@env) + raise "No database for this environment (or subdomain) available!" if @@databases[rails_env].nil? @@databases[rails_env].symbolize_keys end