Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 157 lines (143 sloc) 6.298 kb
3096629 @tenderlove we are *sure* we want to set the encoding, so silence warnings around it
tenderlove authored
1 require 'active_support/core_ext/kernel/reporting'
cd3033e @josevalim Add config.file_watcher so developers can provide their own watchers …
josevalim authored
2 require 'active_support/file_update_checker'
8577687 @spastorino Move queue classes to ActiveSupport
spastorino authored
3 require 'active_support/queueing'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
4 require 'rails/engine/configuration'
5
6 module Rails
7 class Application
8 class Configuration < ::Rails::Engine::Configuration
7dba159 @josh Remove old asset_path from rails config
josh authored
9 attr_accessor :asset_host, :assets, :autoflush_log,
951b582 @drogus Allow to set custom console type with Rails.application.config.console=
drogus authored
10 :cache_classes, :cache_store, :consider_all_requests_local, :console,
e6747d8 @josevalim Allow users to choose when to eager_load the application or not.
josevalim authored
11 :eager_load, :exceptions_app, :file_watcher, :filter_parameters,
1385388 @carlosantoniodasilva Allow configuring a different queue consumer
carlosantoniodasilva authored
12 :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
4faa041 @spastorino Rename secret_token_key to secret_key_base
spastorino authored
13 :railties_order, :relative_url_root, :secret_key_base, :secret_token,
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored
14 :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
e35c67a @kennyj The use_schema_cache_dump configuration moved to ActiveRecord.
kennyj authored
15 :time_zone, :reload_classes_only_on_change,
86e3aaa @freegenie Adding filter capability to ActionController logs
freegenie authored
16 :queue, :queue_consumer, :beginning_of_week, :filter_redirect
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
17
5d23925 @spastorino Use derived keys everywhere, http_authentication was missing it
spastorino authored
18 attr_writer :log_level
4af4312 @tenderlove only define the encoding reader since we define the writer later on
tenderlove authored
19 attr_reader :encoding
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
20
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
21 def initialize(*)
22 super
aaec007 @wycats Make sure apps upgrading from 2.3 get defaulted to UTF-8 (ht: parndt)
wycats authored
23 self.encoding = "utf-8"
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored
24 @consider_all_requests_local = false
25 @filter_parameters = []
86e3aaa @freegenie Adding filter capability to ActionController logs
freegenie authored
26 @filter_redirect = []
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored
27 @helpers_paths = []
28 @serve_static_assets = true
29 @static_cache_control = nil
30 @force_ssl = false
31 @ssl_options = {}
32 @session_store = :cookie_store
33 @session_options = {}
34 @time_zone = "UTC"
da26dfb @gregolsen Date.beginning_of_week thread local and beginning_of_week application…
gregolsen authored
35 @beginning_of_week = :monday
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored
36 @log_level = nil
37 @middleware = app_middleware
38 @generators = app_generators
39 @cache_store = [ :file_store, "#{root}/tmp/cache/" ]
40 @railties_order = [:all]
41 @relative_url_root = ENV["RAILS_RELATIVE_URL_ROOT"]
42 @reload_classes_only_on_change = true
cd3033e @josevalim Add config.file_watcher so developers can provide their own watchers …
josevalim authored
43 @file_watcher = ActiveSupport::FileUpdateChecker
02127e6 @josevalim Allow a custom exceptions app to set.
josevalim authored
44 @exceptions_app = nil
4a98a30 @felixbuenemann Always default to flushing enabled
felixbuenemann authored
45 @autoflush_log = true
51aeae9 @tenderlove allow people to specify custom formatters, use the default formatter …
tenderlove authored
46 @log_formatter = ActiveSupport::Logger::SimpleFormatter.new
c8fe0d5 @jeremy Backpedal from class-oriented config.queue. Set an actual queue insta…
jeremy authored
47 @queue = ActiveSupport::SynchronousQueue.new
1fd8926 @jeremy Test that a Rails.queue consumer is automatically started in production
jeremy authored
48 @queue_consumer = nil
e6747d8 @josevalim Allow users to choose when to eager_load the application or not.
josevalim authored
49 @eager_load = nil
60609bb @spastorino Sign cookies using key deriver
spastorino authored
50 @secret_token = nil
4faa041 @spastorino Rename secret_token_key to secret_key_base
spastorino authored
51 @secret_key_base = nil
28fee29 @josh Unify sprockets config options
josh authored
52
53 @assets = ActiveSupport::OrderedOptions.new
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not i…
josevalim authored
54 @assets.enabled = false
55 @assets.paths = []
117d5e3 @josh Only compile non-js/css under app/assets by default
josh authored
56 @assets.precompile = [ Proc.new { |path, fn| fn =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path)) },
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not i…
josevalim authored
57 /(?:\/|\\|\A)application\.(css|js)$/ ]
58 @assets.prefix = "/assets"
59 @assets.version = ''
60 @assets.debug = false
61 @assets.compile = true
62 @assets.digest = false
a4c358f @guilleiguaran Assets cache shouldn't be shared between different environments
guilleiguaran authored
63 @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/#{Rails.env}/" ]
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not i…
josevalim authored
64 @assets.js_compressor = nil
65 @assets.css_compressor = nil
66 @assets.initialize_on_precompile = true
226783d @guilleiguaran Silent Sprockets logger when config.assets.logger is set to false
guilleiguaran authored
67 @assets.logger = nil
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
68 end
69
70 def encoding=(value)
71 @encoding = value
5ca86ac @lest deprecate String#encoding_aware? and remove its usage
lest authored
72 silence_warnings do
73 Encoding.default_external = value
74 Encoding.default_internal = value
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
75 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
76 end
77
78 def paths
79 @paths ||= begin
80 paths = super
5ad7f8a @robin850 Use Ruby 1.9 Hash syntax in railties
robin850 authored
81 paths.add "config/database", with: "config/database.yml"
82 paths.add "config/environment", with: "config/environment.rb"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
83 paths.add "lib/templates"
5ad7f8a @robin850 Use Ruby 1.9 Hash syntax in railties
robin850 authored
84 paths.add "log", with: "log/#{Rails.env}.log"
afc8288 @josevalim Remove the ability for engines to serve assets from the public direct…
josevalim authored
85 paths.add "public"
86 paths.add "public/javascripts"
87 paths.add "public/stylesheets"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
88 paths.add "tmp"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
89 paths
90 end
91 end
92
93 def threadsafe!
0b7067d @nikitug Provide a call stack for deprecation warnings where needed.
nikitug authored
94 message = "config.threadsafe! is deprecated. Rails applications " \
95 "behave by default as thread safe in production as long as config.cache_classes and " \
96 "config.eager_load are set to true"
b955939 @gazay Make caller attribute in deprecation methods optional
gazay authored
97 ActiveSupport::Deprecation.warn message
76df63e changing self.attribute to @atrribute to follow one kind of value ass…
prasath authored
98 @cache_classes = true
e6747d8 @josevalim Allow users to choose when to eager_load the application or not.
josevalim authored
99 @eager_load = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
100 self
101 end
102
103 # Loads and returns the contents of the #database_configuration_file. The
104 # contents of the file are processed via ERB before being sent through
105 # YAML::load.
106 def database_configuration
107 require 'erb'
3b378a7 @tenderlove use File.binread to pull in the schema cache
tenderlove authored
108 YAML.load ERB.new(IO.read(paths["config/database"].first)).result
61425f2 @gaurish Better Error handling when parsing database.yaml
gaurish authored
109 rescue Psych::SyntaxError => e
110 raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
111 "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
112 "Error: #{e.message}"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
113 end
114
115 def log_level
116 @log_level ||= Rails.env.production? ? :info : :debug
117 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
118
119 def colorize_logging
2e7d6ff @kennyj Remove redundant instance_variables (@colorize_logging)
kennyj authored
120 ActiveSupport::LogSubscriber.colorize_logging
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
121 end
122
123 def colorize_logging=(val)
6788db8 @josevalim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing f…
josevalim authored
124 ActiveSupport::LogSubscriber.colorize_logging = val
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
125 self.generators.colorize_logging = val
126 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
127
128 def session_store(*args)
129 if args.empty?
130 case @session_store
131 when :disabled
132 nil
1807384 @sikachu Raise more helpful error message on missing gem
sikachu authored
133 when :active_record_store
134 begin
135 ActionDispatch::Session::ActiveRecordStore
136 rescue NameError
137 raise "`ActiveRecord::SessionStore` is extracted out of Rails into a gem. " \
138 "Please add `activerecord-session_store` to your Gemfile to use it."
139 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
140 when Symbol
141 ActionDispatch::Session.const_get(@session_store.to_s.camelize)
142 else
143 @session_store
144 end
145 else
146 @session_store = args.shift
147 @session_options = args.shift || {}
148 end
149 end
4f6af26 @lest remove AS whiny nil extension and deprecate config.whiny_nils
lest authored
150
151 def whiny_nils=(*)
b955939 @gazay Make caller attribute in deprecation methods optional
gazay authored
152 ActiveSupport::Deprecation.warn "config.whiny_nils option is deprecated and no longer works"
4f6af26 @lest remove AS whiny nil extension and deprecate config.whiny_nils
lest authored
153 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
154 end
155 end
f38e89c @josh Move railties/builtin into lib
josh authored
156 end
Something went wrong with that request. Please try again.