Fixed multi coop routing and changed config accessors.
This commit is contained in:
parent
2860a3ca44
commit
ec2e761e7f
28 changed files with 124 additions and 88 deletions
|
|
@ -1,10 +1,13 @@
|
|||
# Foodsoft configuration
|
||||
|
||||
development: &defaults
|
||||
default: &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
|
||||
|
||||
# If multi_coop_install you have to use a coop name, which you you wanna be selected by default
|
||||
default_scope: 'f'
|
||||
|
||||
# http config for this host
|
||||
# Required for action mailer
|
||||
protocol: http
|
||||
|
|
@ -75,6 +78,9 @@ development: &defaults
|
|||
100g: 0.1
|
||||
50g: 0.05
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
|
||||
test:
|
||||
<<: *defaults
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,15 @@
|
|||
# Loads and returns config and databases for selected foodcoop.
|
||||
# TODO: When to use class or module. It seems this could also be a Foodsoft-class?
|
||||
module Foodsoft
|
||||
mattr_accessor :env, :config, :database
|
||||
CONFIGS = YAML.load(File.read(File.join(Rails.root, "/config/app_config.yml")))
|
||||
DATABASES = YAML.load(File.read(File.join(Rails.root, "/config/database.yml")))
|
||||
|
||||
class << self
|
||||
def env=(env)
|
||||
raise "No config or database for this environment (#{env}) available!" if CONFIGS[env].nil? or DATABASES[env].nil?
|
||||
@@config = CONFIGS[env].symbolize_keys
|
||||
@@database = DATABASES[env].symbolize_keys
|
||||
@@env = env
|
||||
end
|
||||
end
|
||||
end
|
||||
# Initial load the default config and database from rails environment
|
||||
Foodsoft.env = Rails.env
|
||||
# See config/app_config.yml for further details
|
||||
# Load Config, start by selecting defaults via current environment
|
||||
require 'foodsoft_config'
|
||||
FoodsoftConfig.init
|
||||
|
||||
# Set action mailer default host for url generating
|
||||
url_options = {
|
||||
:host => Foodsoft.config[:host],
|
||||
:protocol => Foodsoft.config[:protocol]
|
||||
:host => FoodsoftConfig[:host],
|
||||
:protocol => FoodsoftConfig[:protocol]
|
||||
}
|
||||
url_options.merge!({:port => Foodsoft.config[:port]}) if Foodsoft.config[:port]
|
||||
url_options.merge!({:port => FoodsoftConfig[:port]}) if FoodsoftConfig[:port]
|
||||
|
||||
Foodsoft::Application.configure do
|
||||
config.action_mailer.default_url_options = url_options
|
||||
|
|
@ -31,9 +18,9 @@ Foodsoft::Application.configure do
|
|||
# Configuration of the exception_notification plugin
|
||||
# Mailadresses are set in config/app_config.yml
|
||||
config.middleware.use ExceptionNotifier,
|
||||
:email_prefix => Foodsoft.config[:notification]['email_prefix'],
|
||||
:sender_address => Foodsoft.config[:notification]['sender_address'],
|
||||
:exception_recipients => Foodsoft.config[:notification]['error_recipients']
|
||||
:email_prefix => FoodsoftConfig[:notification]['email_prefix'],
|
||||
:sender_address => FoodsoftConfig[:notification]['sender_address'],
|
||||
:exception_recipients => FoodsoftConfig[:notification]['error_recipients']
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ Foodsoft::Application.routes.draw do
|
|||
|
||||
get "sessions/new"
|
||||
|
||||
root :to => redirect("/#{Foodsoft.env}")
|
||||
root :to => redirect("/#{FoodsoftConfig.scope}")
|
||||
|
||||
scope '/:foodcoop', :defaults => { :foodcoop => Foodsoft.env } do
|
||||
scope '/:foodcoop' do
|
||||
|
||||
# Root path
|
||||
root :to => 'home#index'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue