2011-08-24 19:23:24 -04:00
|
|
|
require 'active_support/core_ext/kernel/reporting'
|
2011-12-13 03:19:58 -05:00
|
|
|
require 'active_support/file_update_checker'
|
2010-01-23 16:30:17 -05:00
|
|
|
require 'rails/engine/configuration'
|
|
|
|
|
|
|
|
module Rails
|
|
|
|
class Application
|
|
|
|
class Configuration < ::Rails::Engine::Configuration
|
2012-10-15 10:51:20 -04:00
|
|
|
attr_accessor :asset_host, :assets, :autoflush_log,
|
2012-02-01 02:59:21 -05:00
|
|
|
:cache_classes, :cache_store, :consider_all_requests_local, :console,
|
2012-08-01 09:07:01 -04:00
|
|
|
:eager_load, :exceptions_app, :file_watcher, :filter_parameters,
|
2012-05-02 23:10:27 -04:00
|
|
|
:force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
|
2012-11-02 18:27:51 -04:00
|
|
|
:railties_order, :relative_url_root, :secret_key_base, :secret_token,
|
2011-12-12 16:51:33 -05:00
|
|
|
:serve_static_assets, :ssl_options, :static_cache_control, :session_options,
|
2012-08-01 10:16:04 -04:00
|
|
|
:time_zone, :reload_classes_only_on_change,
|
2012-12-21 18:42:47 -05:00
|
|
|
:beginning_of_week, :filter_redirect
|
2010-01-23 16:30:17 -05:00
|
|
|
|
2012-11-02 18:26:11 -04:00
|
|
|
attr_writer :log_level
|
2011-08-24 19:33:36 -04:00
|
|
|
attr_reader :encoding
|
2011-01-05 14:19:09 -05:00
|
|
|
|
2010-01-23 16:30:17 -05:00
|
|
|
def initialize(*)
|
|
|
|
super
|
2010-08-15 19:29:27 -04:00
|
|
|
self.encoding = "utf-8"
|
2011-12-12 16:51:33 -05:00
|
|
|
@consider_all_requests_local = false
|
|
|
|
@filter_parameters = []
|
2012-09-30 18:00:44 -04:00
|
|
|
@filter_redirect = []
|
2011-12-12 16:51:33 -05:00
|
|
|
@helpers_paths = []
|
|
|
|
@serve_static_assets = true
|
|
|
|
@static_cache_control = nil
|
|
|
|
@force_ssl = false
|
|
|
|
@ssl_options = {}
|
|
|
|
@session_store = :cookie_store
|
|
|
|
@session_options = {}
|
|
|
|
@time_zone = "UTC"
|
2012-09-18 10:18:19 -04:00
|
|
|
@beginning_of_week = :monday
|
2011-12-12 16:51:33 -05:00
|
|
|
@log_level = nil
|
|
|
|
@middleware = app_middleware
|
|
|
|
@generators = app_generators
|
|
|
|
@cache_store = [ :file_store, "#{root}/tmp/cache/" ]
|
|
|
|
@railties_order = [:all]
|
|
|
|
@relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
|
|
|
|
@reload_classes_only_on_change = true
|
2011-12-13 03:19:58 -05:00
|
|
|
@file_watcher = ActiveSupport::FileUpdateChecker
|
2011-12-16 03:41:05 -05:00
|
|
|
@exceptions_app = nil
|
2012-02-22 18:38:34 -05:00
|
|
|
@autoflush_log = true
|
2012-03-12 17:25:25 -04:00
|
|
|
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
|
2012-08-01 09:07:01 -04:00
|
|
|
@eager_load = nil
|
2012-10-30 23:06:46 -04:00
|
|
|
@secret_token = nil
|
2012-11-02 18:27:51 -04:00
|
|
|
@secret_key_base = nil
|
2011-03-30 22:56:15 -04:00
|
|
|
|
|
|
|
@assets = ActiveSupport::OrderedOptions.new
|
2013-01-05 11:55:57 -05:00
|
|
|
@assets.enabled = true
|
2011-10-02 06:14:31 -04:00
|
|
|
@assets.paths = []
|
2012-10-16 15:17:41 -04:00
|
|
|
@assets.precompile = [ Proc.new { |path, fn| fn =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path)) },
|
2011-10-02 06:14:31 -04:00
|
|
|
/(?:\/|\\|\A)application\.(css|js)$/ ]
|
|
|
|
@assets.prefix = "/assets"
|
2013-01-05 11:55:57 -05:00
|
|
|
@assets.version = '1.0'
|
2011-10-02 06:14:31 -04:00
|
|
|
@assets.debug = false
|
|
|
|
@assets.compile = true
|
|
|
|
@assets.digest = false
|
2012-09-28 16:20:17 -04:00
|
|
|
@assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/#{Rails.env}/" ]
|
2011-10-02 06:14:31 -04:00
|
|
|
@assets.js_compressor = nil
|
|
|
|
@assets.css_compressor = nil
|
|
|
|
@assets.initialize_on_precompile = true
|
2012-01-17 22:05:56 -05:00
|
|
|
@assets.logger = nil
|
2010-04-06 20:24:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def encoding=(value)
|
|
|
|
@encoding = value
|
2011-12-24 07:57:54 -05:00
|
|
|
silence_warnings do
|
|
|
|
Encoding.default_external = value
|
|
|
|
Encoding.default_internal = value
|
2010-04-06 20:24:29 -04:00
|
|
|
end
|
2010-01-23 16:30:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def paths
|
|
|
|
@paths ||= begin
|
|
|
|
paths = super
|
2012-10-14 06:03:39 -04:00
|
|
|
paths.add "config/database", with: "config/database.yml"
|
|
|
|
paths.add "config/environment", with: "config/environment.rb"
|
2010-10-06 11:18:59 -04:00
|
|
|
paths.add "lib/templates"
|
2012-10-14 06:03:39 -04:00
|
|
|
paths.add "log", with: "log/#{Rails.env}.log"
|
2011-04-15 13:57:52 -04:00
|
|
|
paths.add "public"
|
|
|
|
paths.add "public/javascripts"
|
|
|
|
paths.add "public/stylesheets"
|
2010-10-06 11:18:59 -04:00
|
|
|
paths.add "tmp"
|
2010-01-23 16:30:17 -05:00
|
|
|
paths
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def threadsafe!
|
2012-10-29 11:22:59 -04:00
|
|
|
message = "config.threadsafe! is deprecated. Rails applications " \
|
|
|
|
"behave by default as thread safe in production as long as config.cache_classes and " \
|
|
|
|
"config.eager_load are set to true"
|
2012-10-29 22:23:41 -04:00
|
|
|
ActiveSupport::Deprecation.warn message
|
2012-01-11 14:57:30 -05:00
|
|
|
@cache_classes = true
|
2012-08-01 09:07:01 -04:00
|
|
|
@eager_load = true
|
2010-01-23 16:30:17 -05:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2013-02-21 10:11:28 -05:00
|
|
|
# Loads and returns the contents of the #paths["config/database"]. The
|
2010-01-23 16:30:17 -05:00
|
|
|
# contents of the file are processed via ERB before being sent through
|
|
|
|
# YAML::load.
|
|
|
|
def database_configuration
|
2013-02-20 09:13:10 -05:00
|
|
|
if ENV['DATABASE_URL']
|
|
|
|
{Rails.env => ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.connection_url_to_hash(ENV['DATABASE_URL']).stringify_keys}
|
|
|
|
else
|
|
|
|
require 'erb'
|
|
|
|
YAML.load ERB.new(IO.read(paths["config/database"].first)).result
|
|
|
|
end
|
2012-11-20 05:48:28 -05:00
|
|
|
rescue Psych::SyntaxError => e
|
|
|
|
raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
|
|
|
|
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
|
|
|
"Error: #{e.message}"
|
2010-01-23 16:30:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def log_level
|
|
|
|
@log_level ||= Rails.env.production? ? :info : :debug
|
|
|
|
end
|
2010-03-02 16:05:25 -05:00
|
|
|
|
|
|
|
def colorize_logging
|
2012-01-27 09:01:14 -05:00
|
|
|
ActiveSupport::LogSubscriber.colorize_logging
|
2010-03-02 16:05:25 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def colorize_logging=(val)
|
2010-06-24 07:23:43 -04:00
|
|
|
ActiveSupport::LogSubscriber.colorize_logging = val
|
2010-03-02 16:05:25 -05:00
|
|
|
self.generators.colorize_logging = val
|
|
|
|
end
|
2010-03-26 13:47:55 -04:00
|
|
|
|
|
|
|
def session_store(*args)
|
|
|
|
if args.empty?
|
|
|
|
case @session_store
|
|
|
|
when :disabled
|
|
|
|
nil
|
2012-08-24 17:02:27 -04:00
|
|
|
when :active_record_store
|
|
|
|
begin
|
|
|
|
ActionDispatch::Session::ActiveRecordStore
|
|
|
|
rescue NameError
|
|
|
|
raise "`ActiveRecord::SessionStore` is extracted out of Rails into a gem. " \
|
|
|
|
"Please add `activerecord-session_store` to your Gemfile to use it."
|
|
|
|
end
|
2010-03-26 13:47:55 -04:00
|
|
|
when Symbol
|
|
|
|
ActionDispatch::Session.const_get(@session_store.to_s.camelize)
|
|
|
|
else
|
|
|
|
@session_store
|
|
|
|
end
|
|
|
|
else
|
|
|
|
@session_store = args.shift
|
|
|
|
@session_options = args.shift || {}
|
|
|
|
end
|
|
|
|
end
|
2011-12-20 14:18:23 -05:00
|
|
|
|
|
|
|
def whiny_nils=(*)
|
2012-10-29 22:23:41 -04:00
|
|
|
ActiveSupport::Deprecation.warn "config.whiny_nils option is deprecated and no longer works"
|
2011-12-20 14:18:23 -05:00
|
|
|
end
|
2010-01-23 16:30:17 -05:00
|
|
|
end
|
|
|
|
end
|
2010-03-20 13:34:21 -04:00
|
|
|
end
|