foodsoft/config/initializers/load_app_config.rb
Benjamin Meichsner f49c6493f4 Removed hard coded links from mailer and views.
* Not tested every mail template. Hopefully everything works ;-)
2010-03-20 14:49:46 +01:00

32 lines
1.3 KiB
Ruby

# 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(RAILS_ROOT + "/config/app_config.yml"))
DATABASES = YAML.load(File.read(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
# Set action mailer default host for url generating
ActionMailer::Base.default_url_options = {
:host => Foodsoft.config[:host],
:port => Foodsoft.config[:port],
:protocol => Foodsoft.config[:protocol]
}
# Configuration of the exception_notification plugin
# Mailadresses are set in config/foodsoft.yaml
ExceptionNotifier.exception_recipients = Foodsoft.config[:notification]['error_recipients']
ExceptionNotifier.sender_address = Foodsoft.config[:notification]['sender_address']
ExceptionNotifier.email_prefix = Foodsoft.config[:notification]['email_prefix']