Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 160 lines (146 sloc) 6.275 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'
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
3 require 'rails/engine/configuration'
4
5 module Rails
6 class Application
7 class Configuration < ::Rails::Engine::Configuration
9ee6f3c @josevalim Bring config.allow_concurrency back
josevalim authored
8 attr_accessor :allow_concurrency, :asset_host, :assets, :autoflush_log,
951b582 @drogus Allow to set custom console type with Rails.application.config.console=
drogus authored
9 :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
10 :eager_load, :exceptions_app, :file_watcher, :filter_parameters,
1385388 @carlosantoniodasilva Allow configuring a different queue consumer
carlosantoniodasilva authored
11 :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
4faa041 @spastorino Rename secret_token_key to secret_key_base
spastorino authored
12 :railties_order, :relative_url_root, :secret_key_base, :secret_token,
fa1d9a8 @josevalim Speed up development by only reloading classes if dependencies files …
josevalim authored
13 :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
e35c67a @kennyj The use_schema_cache_dump configuration moved to ActiveRecord.
kennyj authored
14 :time_zone, :reload_classes_only_on_change,
f9da785 @jeremy Move background jobs to the 'jobs' branch until fully baked. Not ship…
jeremy authored
15 :beginning_of_week, :filter_redirect
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
16
5d23925 @spastorino Use derived keys everywhere, http_authentication was missing it
spastorino authored
17 attr_writer :log_level
4af4312 @tenderlove only define the encoding reader since we define the writer later on
tenderlove authored
18 attr_reader :encoding
64c82f9 @tenderlove only define log_level reader once, make sure to initialize @log_level
tenderlove authored
19
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
20 def initialize(*)
21 super
aaec007 @wycats Make sure apps upgrading from 2.3 get defaulted to UTF-8 (ht: parndt)
wycats authored
22 self.encoding = "utf-8"
9ee6f3c @josevalim Bring config.allow_concurrency back
josevalim authored
23 @allow_concurrency = nil
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
e6747d8 @josevalim Allow users to choose when to eager_load the application or not.
josevalim authored
47 @eager_load = nil
60609bb @spastorino Sign cookies using key deriver
spastorino authored
48 @secret_token = nil
4faa041 @spastorino Rename secret_token_key to secret_key_base
spastorino authored
49 @secret_key_base = nil
28fee29 @josh Unify sprockets config options
josh authored
50
51 @assets = ActiveSupport::OrderedOptions.new
201f8d7 @dhh config.assets.enabled is now true by default
dhh authored
52 @assets.enabled = true
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not i…
josevalim authored
53 @assets.paths = []
117d5e3 @josh Only compile non-js/css under app/assets by default
josh authored
54 @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
55 /(?:\/|\\|\A)application\.(css|js)$/ ]
56 @assets.prefix = "/assets"
201f8d7 @dhh config.assets.enabled is now true by default
dhh authored
57 @assets.version = '1.0'
7534240 @josevalim Provide initialize_on_precompile which, when set to false, does not i…
josevalim authored
58 @assets.debug = false
59 @assets.compile = true
60 @assets.digest = false
a4c358f @guilleiguaran Assets cache shouldn't be shared between different environments
guilleiguaran authored
61 @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
62 @assets.js_compressor = nil
63 @assets.css_compressor = nil
64 @assets.initialize_on_precompile = true
226783d @guilleiguaran Silent Sprockets logger when config.assets.logger is set to false
guilleiguaran authored
65 @assets.logger = nil
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
66 end
67
68 def encoding=(value)
69 @encoding = value
5ca86ac @lest deprecate String#encoding_aware? and remove its usage
lest authored
70 silence_warnings do
71 Encoding.default_external = value
72 Encoding.default_internal = value
ec73710 @josevalim Alleviate the pain in working with utf8 templates by setting a defaul…
josevalim authored
73 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
74 end
75
76 def paths
77 @paths ||= begin
78 paths = super
5ad7f8a @robin850 Use Ruby 1.9 Hash syntax in railties
robin850 authored
79 paths.add "config/database", with: "config/database.yml"
80 paths.add "config/environment", with: "config/environment.rb"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
81 paths.add "lib/templates"
5ad7f8a @robin850 Use Ruby 1.9 Hash syntax in railties
robin850 authored
82 paths.add "log", with: "log/#{Rails.env}.log"
afc8288 @josevalim Remove the ability for engines to serve assets from the public direct…
josevalim authored
83 paths.add "public"
84 paths.add "public/javascripts"
85 paths.add "public/stylesheets"
d649bf1 @josevalim Provide a cleaner syntax for paths configuration that does not rely o…
josevalim authored
86 paths.add "tmp"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
87 paths
88 end
89 end
90
91 def threadsafe!
0b7067d @nikitug Provide a call stack for deprecation warnings where needed.
nikitug authored
92 message = "config.threadsafe! is deprecated. Rails applications " \
93 "behave by default as thread safe in production as long as config.cache_classes and " \
94 "config.eager_load are set to true"
b955939 @gazay Make caller attribute in deprecation methods optional
gazay authored
95 ActiveSupport::Deprecation.warn message
76df63e changing self.attribute to @atrribute to follow one kind of value ass…
prasath authored
96 @cache_classes = true
e6747d8 @josevalim Allow users to choose when to eager_load the application or not.
josevalim authored
97 @eager_load = true
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
98 self
99 end
100
7b6f2a0 @iwiznia Update railties/lib/rails/application/configuration.rb
iwiznia authored
101 # Loads and returns the configuration of the database.
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
102 def database_configuration
dd5a80d @josevalim Remove hard coded references to Active Record in railties
josevalim authored
103 yaml = paths["config/database"].first
104 if File.exists?(yaml)
105 require "erb"
106 YAML.load ERB.new(IO.read(yaml)).result
107 elsif ENV['DATABASE_URL']
108 nil
4bdaf95 @hone standardize database_configuration to a hash
hone authored
109 else
dd5a80d @josevalim Remove hard coded references to Active Record in railties
josevalim authored
110 raise "Could not load database configuration. No such file - #{yaml}"
4bdaf95 @hone standardize database_configuration to a hash
hone authored
111 end
61425f2 @gaurish Better Error handling when parsing database.yaml
gaurish authored
112 rescue Psych::SyntaxError => e
113 raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
114 "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
115 "Error: #{e.message}"
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
116 end
117
118 def log_level
119 @log_level ||= Rails.env.production? ? :info : :debug
120 end
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
121
122 def colorize_logging
2e7d6ff @kennyj Remove redundant instance_variables (@colorize_logging)
kennyj authored
123 ActiveSupport::LogSubscriber.colorize_logging
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
124 end
125
126 def colorize_logging=(val)
6788db8 @josevalim Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing f…
josevalim authored
127 ActiveSupport::LogSubscriber.colorize_logging = val
c2dbc39 Have log subscribers subscribe to the actual events, so the subscribe…
Carlhuda authored
128 self.generators.colorize_logging = val
129 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
130
131 def session_store(*args)
132 if args.empty?
133 case @session_store
134 when :disabled
135 nil
1807384 @sikachu Raise more helpful error message on missing gem
sikachu authored
136 when :active_record_store
137 begin
138 ActionDispatch::Session::ActiveRecordStore
139 rescue NameError
140 raise "`ActiveRecord::SessionStore` is extracted out of Rails into a gem. " \
141 "Please add `activerecord-session_store` to your Gemfile to use it."
142 end
395d664 @josevalim Move application configuration to the application configuration objec…
josevalim authored
143 when Symbol
144 ActionDispatch::Session.const_get(@session_store.to_s.camelize)
145 else
146 @session_store
147 end
148 else
149 @session_store = args.shift
150 @session_options = args.shift || {}
151 end
152 end
4f6af26 @lest remove AS whiny nil extension and deprecate config.whiny_nils
lest authored
153
154 def whiny_nils=(*)
b955939 @gazay Make caller attribute in deprecation methods optional
gazay authored
155 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
156 end
b17e358 @josevalim Move configuration to subfolders.
josevalim authored
157 end
158 end
f38e89c @josh Move railties/builtin into lib
josh authored
159 end
Something went wrong with that request. Please try again.