aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenare Degan <henare.degan@gmail.com>2012-12-09 17:36:08 +1100
committerHenare Degan <henare.degan@gmail.com>2012-12-11 11:09:31 +1100
commitfc01d919936e016daf841ec734f9dd8fd97a5f60 (patch)
treec8b8d557f1235b97faf2cac50767362a9e497e2e
parent92eff943b20e6658b92dfaa7e83ff5a70dbc93d4 (diff)
Move Rails config over
-rw-r--r--config/application.rb26
-rw-r--r--config/initializers/alaveteli.rb57
-rw-r--r--lib/configuration.rb10
3 files changed, 36 insertions, 57 deletions
diff --git a/config/application.rb b/config/application.rb
index 91bb930fa..b19e20221 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -2,6 +2,8 @@ require File.expand_path('../boot', __FILE__)
require 'rails/all'
+require File.dirname(__FILE__) + '/../lib/configuration'
+
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
@@ -38,5 +40,29 @@ module Alaveteli
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ config.active_record.schema_format = :sql
+
+ # Make Active Record use UTC-base instead of local time
+ config.active_record.default_timezone = :utc
+
+ # This is the timezone that times and dates are displayed in
+ # Note that having set a zone, the Active Record
+ # time_zone_aware_attributes flag is on, so times from models
+ # will be in this time zone
+ config.time_zone = ::Configuration::time_zone
+
+ config.after_initialize do
+ require 'routing_filters.rb'
+ end
+
+ config.autoload_paths << "#{RAILS_ROOT}/lib/mail_handler"
+
+ # See Rails::Configuration for more options
+ ENV['RECAPTCHA_PUBLIC_KEY'] = ::Configuration::recaptcha_public_key
+ ENV['RECAPTCHA_PRIVATE_KEY'] = ::Configuration::recaptcha_private_key
end
end
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb
index a2b9b5c38..3f1a56249 100644
--- a/config/initializers/alaveteli.rb
+++ b/config/initializers/alaveteli.rb
@@ -22,67 +22,10 @@ load "config.rb"
load "format.rb"
load "debug_helpers.rb"
load "util.rb"
-require 'configuration'
# Application version
ALAVETELI_VERSION = '0.6.8'
-Rails::Initializer.run do |config|
- # Load intial mySociety config
- if ENV["RAILS_ENV"] == "test"
- MySociety::Config.set_file(File.join(config.root_path, 'config', 'test'), true)
- else
- MySociety::Config.set_file(File.join(config.root_path, 'config', 'general'), true)
- end
- MySociety::Config.load_default
-
- # Settings in config/environments/* take precedence over those specified here
-
- # Skip frameworks you're not going to use (only works if using vendor/rails)
- # config.frameworks -= [ :action_web_service, :action_mailer ]
-
- # Only load the plugins named here, by default all plugins in vendor/plugins are loaded
- # config.plugins = %W( exception_notification ssl_requirement )
-
- # Add additional load paths for your own custom dirs
- # config.load_paths += %W( #{Rails.root}/extras )
-
- # Force all environments to use the same logger level
- # (by default production uses :info, the others :debug)
- # TEMP: uncomment this to turn on logging in production environments
- # config.log_level = :debug
- #
- # Specify gems that this application depends on and have them installed with rake gems:install
- #GettextI18nRails.translations_are_html_safe = true
-
- # Use SQL instead of Active Record's schema dumper when creating the test database.
- # This is necessary if your schema can't be completely dumped by the schema dumper,
- # like if you have constraints or database-specific column types
- config.active_record.schema_format = :sql
-
- # Activate observers that should always be running
- # config.active_record.observers = :cacher, :garbage_collector
-
- # Make Active Record use UTC-base instead of local time
- config.active_record.default_timezone = :utc
-
- # This is the timezone that times and dates are displayed in
- # Note that having set a zone, the Active Record
- # time_zone_aware_attributes flag is on, so times from models
- # will be in this time zone
- config.time_zone = Configuration::time_zone
-
- config.after_initialize do
- require 'routing_filters.rb'
- end
-
- config.autoload_paths << "#{RAILS_ROOT}/lib/mail_handler"
-
- # See Rails::Configuration for more options
- ENV['RECAPTCHA_PUBLIC_KEY'] = Configuration::recaptcha_public_key
- ENV['RECAPTCHA_PRIVATE_KEY'] = Configuration::recaptcha_private_key
-end
-
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
diff --git a/lib/configuration.rb b/lib/configuration.rb
index 11fe1c56e..9c369b2e7 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -1,3 +1,13 @@
+require File.dirname(__FILE__) + '/../commonlib/rblib/config'
+
+# Load intial mySociety config
+if ENV["RAILS_ENV"] == "test"
+ MySociety::Config.set_file(File.join(File.dirname(__FILE__), 'test'), true)
+else
+ MySociety::Config.set_file(File.join(File.dirname(__FILE__), 'general'), true)
+end
+MySociety::Config.load_default
+
# Configuration values with defaults
# TODO: Make this return different values depending on the current rails environment