Skip to content
This repository
Newer
Older
100644 209 lines (182 sloc) 7.093 kb
6690d662 » josevalim
2010-04-05 Rename config.cookie_secret to config.secret_token and pass it as con…
1 require 'active_support/core_ext/hash/reverse_merge'
772c2b0b » josevalim
2010-06-20 Use the new ActiveSupport::FileUpdateChecker instead of RoutesReloader.
2 require 'active_support/file_update_checker'
02c5137e » josevalim
2010-01-22 Add view paths to Engine setup.
3 require 'fileutils'
b17e358e » josevalim
2010-01-23 Move configuration to subfolders.
4 require 'rails/plugin'
2fde9d77 » josevalim
2010-01-24 Solve some pendencies.
5 require 'rails/engine'
dc677f76 » Carlhuda
2009-12-22 tests pass with requiring the frameworks in rails.rb
6
accd9b46 » josh
2009-09-25 Restore "Start Rails::Application object
7 module Rails
781d0a9b » josevalim
2010-02-02 Add docs for Railtie, Engine, Plugin and Application.
8 # In Rails 3.0, a Rails::Application object was introduced which is nothing more than
9 # an Engine but with the responsibility of coordinating the whole boot process.
10 #
11 # == Initialization
12 #
13 # Rails::Application is responsible for executing all railties, engines and plugin
eb716f63 » mjankowski
2011-07-12 grammar/tense correction to rails application doc
14 # initializers. It also executes some bootstrap initializers (check
781d0a9b » josevalim
2010-02-02 Add docs for Railtie, Engine, Plugin and Application.
15 # Rails::Application::Bootstrap) and finishing initializers, after all the others
16 # are executed (check Rails::Application::Finisher).
17 #
18 # == Configuration
19 #
20 # Besides providing the same configuration as Rails::Engine and Rails::Railtie,
21 # the application object has several specific configurations, for example
22 # "allow_concurrency", "cache_classes", "consider_all_requests_local", "filter_parameters",
9b19a6f1 » josevalim
2010-06-28 A few changes were done in this commit:
23 # "logger", "reload_plugins" and so forth.
781d0a9b » josevalim
2010-02-02 Add docs for Railtie, Engine, Plugin and Application.
24 #
25 # Check Rails::Application::Configuration to see them all.
26 #
27 # == Routes
28 #
29 # The application object is also responsible for holding the routes and reloading routes
30 # whenever the files change in development.
31 #
45e60283 » wycats
2010-05-29 Removing Metal from Rails 3.
32 # == Middlewares
781d0a9b » josevalim
2010-02-02 Add docs for Railtie, Engine, Plugin and Application.
33 #
45e60283 » wycats
2010-05-29 Removing Metal from Rails 3.
34 # The Application is also responsible for building the middleware stack.
9cfeefb6 » wycats
2010-05-15 Reorganized initializers a bit to enable better hooks for common case…
35 #
7fcf8590 » josevalim
2010-01-21 Massive cleanup in Railties and load stack.
36 class Application < Engine
4f036032 » josevalim
2010-01-23 Break application.rb file in smaller chunks.
37 autoload :Bootstrap, 'rails/application/bootstrap'
b17e358e » josevalim
2010-01-23 Move configuration to subfolders.
38 autoload :Configuration, 'rails/application/configuration'
4f036032 » josevalim
2010-01-23 Break application.rb file in smaller chunks.
39 autoload :Finisher, 'rails/application/finisher'
13d66cdf » josevalim
2010-01-23 Extract Railtie load from application.
40 autoload :Railties, 'rails/application/railties'
3049e645 » drogus
2010-09-29 Moved Rails::RoutesReloader to Rails::Application::RoutesReloader
41 autoload :RoutesReloader, 'rails/application/routes_reloader'
80130d12 » josevalim
2010-01-23 Extract routes reloading responsibilities from application and load t…
42
e4d7e509 » Carl Lerche
2009-10-08 Moving more initializers into the application object
43 class << self
7fcf8590 » josevalim
2010-01-21 Massive cleanup in Railties and load stack.
44 def inherited(base)
2fde9d77 » josevalim
2010-01-24 Solve some pendencies.
45 raise "You cannot have more than one Rails::Application" if Rails.application
7fcf8590 » josevalim
2010-01-21 Massive cleanup in Railties and load stack.
46 super
788fce25 » josevalim
2010-01-23 Create configurable modules and ensure that they are added only on di…
47 Rails.application = base.instance
6f83a503 » fxn
2010-06-22 renames load_(once_)paths to autoload_(once_)paths in dependencies an…
48 Rails.application.add_lib_to_load_path!
9cfeefb6 » wycats
2010-05-15 Reorganized initializers a bit to enable better hooks for common case…
49 ActiveSupport.run_load_hooks(:before_configuration, base.instance)
e4d7e509 » Carl Lerche
2009-10-08 Moving more initializers into the application object
50 end
897164dd » Yehuda Katz + Carl Lerche
2009-11-02 Conceptually unify instance & global initializers
51 end
6f6a589d » Yehuda Katz + Carl Lerche
2009-09-28 Create the application object from config/environment.rb
52
52e01fc5 » josevalim
2011-05-25 Everyone receives app as argument for consistency.
53 attr_accessor :assets, :sandbox
54 alias_method :sandbox?, :sandbox
55
eedbf87d » drogus
2010-07-08 New way of generating urls for Application from Engine.
56 delegate :default_url_options, :default_url_options=, :to => :routes
57
44f07098 » tenderlove
2011-08-24 dealing with some -w warnings on startup
58 def initialize
59 super
60 @initialized = false
61 end
62
9e081cae » josevalim
2010-06-20 Improve documentation for add_lib_to_load_paths!
63 # This method is called just after an application inherits from Rails::Application,
64 # allowing the developer to load classes in lib and use them during application
65 # configuration.
66 #
67 # class MyApplication < Rails::Application
68 # require "my_backend" # in lib/my_backend
69 # config.i18n.backend = MyBackend
70 # end
71 #
72 # Notice this method takes into consideration the default root path. So if you
73 # are changing config.root inside your application definition or having a custom
74 # Rails application, you will need to add lib to $LOAD_PATH on your own in case
75 # you need to load files in lib/ during the application configuration as well.
6f83a503 » fxn
2010-06-22 renames load_(once_)paths to autoload_(once_)paths in dependencies an…
76 def add_lib_to_load_path! #:nodoc:
5a0d73f1 » josevalim
2010-06-02 Add lib to load paths when application is inherited to be able to loa…
77 path = config.root.join('lib').to_s
78 $LOAD_PATH.unshift(path) if File.exists?(path)
79 end
80
9e081cae » josevalim
2010-06-20 Improve documentation for add_lib_to_load_paths!
81 def require_environment! #:nodoc:
d649bf15 » josevalim
2010-10-06 Provide a cleaner syntax for paths configuration that does not rely o…
82 environment = paths["config/environment"].existent.first
13d66cdf » josevalim
2010-01-23 Extract Railtie load from application.
83 require environment if environment
d982fe2b » Carlhuda
2009-12-21 Replace reopening the class with App.configure as an alias to class_eval
84 end
85
7b0c592e » josevalim
2010-10-02 reload_routes! is part of the public API and should not be removed.
86 def reload_routes!
87 routes_reloader.reload!
88 end
89
80130d12 » josevalim
2010-01-23 Extract routes reloading responsibilities from application and load t…
90 def routes_reloader
3049e645 » drogus
2010-09-29 Moved Rails::RoutesReloader to Rails::Application::RoutesReloader
91 @routes_reloader ||= RoutesReloader.new
80130d12 » josevalim
2010-01-23 Extract routes reloading responsibilities from application and load t…
92 end
5f8e48cb » josh
2009-12-14 Move route reloading into railties
93
eb367afe » josevalim
2011-09-24 `rake assets:precompile` loads the application but does not initializ…
94 def initialize!(group=nil)
abeb0ff2 » drogus
2010-07-22 Ensure that Rails.application.initialize! is called only once
95 raise "Application has been already initialized." if @initialized
eb367afe » josevalim
2011-09-24 `rake assets:precompile` loads the application but does not initializ…
96 run_initializers(group, self)
abeb0ff2 » drogus
2010-07-22 Ensure that Rails.application.initialize! is called only once
97 @initialized = true
80130d12 » josevalim
2010-01-23 Extract routes reloading responsibilities from application and load t…
98 self
5f8e48cb » josh
2009-12-14 Move route reloading into railties
99 end
100
52e01fc5 » josevalim
2011-05-25 Everyone receives app as argument for consistency.
101 def load_tasks(app=self)
788fce25 » josevalim
2010-01-23 Create configurable modules and ensure that they are added only on di…
102 initialize_tasks
e461e1bc » josevalim
2010-04-26 Ensure application rake tasks and generators are loaded after the one…
103 super
13d66cdf » josevalim
2010-01-23 Extract Railtie load from application.
104 self
94bb3316 » jeremy
2009-12-23 Shift more responsibility from application class to its singleton ins…
105 end
106
52e01fc5 » josevalim
2011-05-25 Everyone receives app as argument for consistency.
107 def load_console(app=self)
594b749f » josevalim
2011-05-25 Streamline generators initialization flow.
108 initialize_console
52e01fc5 » josevalim
2011-05-25 Everyone receives app as argument for consistency.
109 super
fa98eca7 » josevalim
2010-07-17 Add console hook to force ActiveRecord::Base to be loaded when consol…
110 self
111 end
112
ea649de6 » franckverrot
2011-07-11 Rails.application#env_config is now public API. [Closes #1924]
113 # Rails.application.env_config stores some of the Rails initial environment parameters.
114 # Currently stores:
115 #
116 # * action_dispatch.parameter_filter" => config.filter_parameters,
117 # * action_dispatch.secret_token" => config.secret_token,
118 # * action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions
119 #
120 # These parameters will be used by middlewares and engines to configure themselves.
121 #
a132229d » drogus
2010-07-22 Added ability to set asset_path for engines
122 def env_config
123 @env_config ||= super.merge({
6690d662 » josevalim
2010-04-05 Rename config.cookie_secret to config.secret_token and pass it as con…
124 "action_dispatch.parameter_filter" => config.filter_parameters,
a132229d » drogus
2010-07-22 Added ability to set asset_path for engines
125 "action_dispatch.secret_token" => config.secret_token,
439a7452 » sikachu
2011-02-23 Make sure that we set `env["action_dispatch.show_exceptions"]`
126 "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions
a132229d » drogus
2010-07-22 Added ability to set asset_path for engines
127 })
6d6ae084 » Carl Lerche
2009-10-07 Start moving the initializers into the application object
128 end
129
98240c49 » josevalim
2010-01-23 Get rid of initializers global and create i18n railtie.
130 def initializers
e9793c60 » spastorino
2010-10-08 Makes this code a bit more clear
131 Bootstrap.initializers_for(self) +
132 super +
133 Finisher.initializers_for(self)
98240c49 » josevalim
2010-01-23 Get rid of initializers global and create i18n railtie.
134 end
788fce25 » josevalim
2010-01-23 Create configurable modules and ensure that they are added only on di…
135
32a5b499 » drogus
2010-07-19 Move singleton pattern to Railtie and remove Engine::Configurable and…
136 def config
137 @config ||= Application::Configuration.new(find_root_with_flag("config.ru", Dir.pwd))
138 end
139
8496be7e » guilleiguaran
2011-06-06 Fixing Rails::Server#app under Rack::URLMap
140 def to_app
141 self
142 end
143
2fe70c18 » josevalim
2011-04-15 Booya, sprockets now works from Engines.
144 protected
145
146 alias :build_middleware_stack :app
612454e0 » josh
2011-03-29 Move sprockets initializers back to application
147
19d8c8cb » josevalim
2010-05-29 Remove the laziness from the middleware stack.
148 def default_middleware_stack
149 ActionDispatch::MiddlewareStack.new.tap do |middleware|
2c0c4d75 » sikachu
2011-03-27 Add `config.force_ssl` configuration which will load `Rack::SSL` midd…
150 if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache
151 require "action_dispatch/http/rack_cache"
152 middleware.use ::Rack::Cache, rack_cache
153 end
254ab7d9 » wycats
2010-09-13 First pass at Rack::Cache
154
2c0c4d75 » sikachu
2011-03-27 Add `config.force_ssl` configuration which will load `Rack::SSL` midd…
155 if config.force_ssl
156 require "rack/ssl"
cb5c39f8 » jsl
2011-09-26 Make the Rack::SSL middleware configurable
157 middleware.use ::Rack::SSL, config.ssl_options
2c0c4d75 » sikachu
2011-03-27 Add `config.force_ssl` configuration which will load `Rack::SSL` midd…
158 end
eeb32469 » Sparky
2010-09-15 Only add Rack::Cache to the middleware stack if config.action_control…
159
e6369bc9 » drogus
2011-02-09 Application's assets should have higher priority than engine's ones
160 if config.serve_static_assets
1ca81238 » josevalim
2011-05-03 Add static_cache_control as configuration option and set a default fo…
161 middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control
e6369bc9 » drogus
2011-02-09 Application's assets should have higher priority than engine's ones
162 end
2c0c4d75 » sikachu
2011-03-27 Add `config.force_ssl` configuration which will load `Rack::SSL` midd…
163
ea14396c » neerajdotname
2010-10-16 replace if ! with unless
164 middleware.use ::Rack::Lock unless config.allow_concurrency
19d8c8cb » josevalim
2010-05-29 Remove the laziness from the middleware stack.
165 middleware.use ::Rack::Runtime
17a91a6e » dlee
2011-05-07 Logs should show overridden method; Issue 426
166 middleware.use ::Rack::MethodOverride
167 middleware.use ::Rails::Rack::Logger # must come after Rack::MethodOverride to properly log overridden methods
515ea955 » sikachu
2011-02-23 Always use ActionDispatch::ShowExceptions middleware [#6462 state:res…
168 middleware.use ::ActionDispatch::ShowExceptions, config.consider_all_requests_local
19d8c8cb » josevalim
2010-05-29 Remove the laziness from the middleware stack.
169 middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
19ac034b » spastorino
2011-07-25 Don't use Rack::Sendfile middleware if x_sendfile_header is not present
170 if config.action_dispatch.x_sendfile_header.present?
171 middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
172 end
0f7c970e » John Firebaugh
2010-11-23 Introduce ActionDispatch::Reloader
173 middleware.use ::ActionDispatch::Reloader unless config.cache_classes
435bccda » John Firebaugh
2010-12-19 Replace AD::Callbacks.to_prepare with AD::Reloader.to_prepare
174 middleware.use ::ActionDispatch::Callbacks
19d8c8cb » josevalim
2010-05-29 Remove the laziness from the middleware stack.
175 middleware.use ::ActionDispatch::Cookies
176
177 if config.session_store
178 middleware.use config.session_store, config.session_options
179 middleware.use ::ActionDispatch::Flash
180 end
181
182 middleware.use ::ActionDispatch::ParamsParser
183 middleware.use ::ActionDispatch::Head
74dd8a36 » josevalim
2010-09-22 Move ETag and ConditionalGet logic from AD::Response to the middlewar…
184 middleware.use ::Rack::ConditionalGet
185 middleware.use ::Rack::ETag, "no-cache"
2c0c4d75 » sikachu
2011-03-27 Add `config.force_ssl` configuration which will load `Rack::SSL` midd…
186
187 if config.action_dispatch.best_standards_support
188 middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support
189 end
19d8c8cb » josevalim
2010-05-29 Remove the laziness from the middleware stack.
190 end
191 end
192
788fce25 » josevalim
2010-01-23 Create configurable modules and ensure that they are added only on di…
193 def initialize_tasks
e2908356 » bilts
2011-05-20 Make Rake::DSL methods available within Railtie rake_tasks block
194 self.class.rake_tasks do
195 require "rails/tasks"
196 task :environment do
197 $rails_rake_task = true
198 require_environment!
199 end
788fce25 » josevalim
2010-01-23 Create configurable modules and ensure that they are added only on di…
200 end
201 end
202
594b749f » josevalim
2011-05-25 Streamline generators initialization flow.
203 def initialize_console
d54c7781 » amatsuda
2011-05-18 always enable `pp` on the Rails console
204 require "pp"
fa98eca7 » josevalim
2010-07-17 Add console hook to force ActiveRecord::Base to be loaded when consol…
205 require "rails/console/app"
206 require "rails/console/helpers"
207 end
accd9b46 » josh
2009-09-25 Restore "Start Rails::Application object
208 end
17a91a6e » dlee
2011-05-07 Logs should show overridden method; Issue 426
209 end
Something went wrong with that request. Please try again.