diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails/engine/configuration.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/railtie/configuration.rb | 2 |
4 files changed, 15 insertions, 5 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index a20208f8d5..14669f47b7 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -11,7 +11,7 @@ module Rails :encoding, :consider_all_requests_local, :dependency_loading, :filter_parameters, :log_level, :logger, :preload_frameworks, :reload_plugins, - :secret_token, :serve_static_assets, :session_options, + :secret_token, :session_options, :time_zone, :whiny_nils def initialize(*) diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index c0607950b5..409502cb08 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -152,13 +152,22 @@ module Rails end def app - @app ||= config.middleware.build(endpoint) + @app ||= begin + config.middleware = config.middleware.merge_into(default_middleware_stack) + config.middleware.build(endpoint) + end end def endpoint self.class.endpoint || routes end + def default_middleware_stack + ActionDispatch::MiddlewareStack.new.tap do |middleware| + middleware.use ::ActionDispatch::Static, paths.public.to_a.first if config.serve_static_assets + end + end + def call(env) app.call(env) end diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 0c91796fc9..b1adbe1f22 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -5,12 +5,13 @@ module Rails class Configuration < ::Rails::Railtie::Configuration attr_reader :root attr_writer :eager_load_paths, :autoload_once_paths, :autoload_paths - attr_accessor :middleware, :plugins + attr_accessor :middleware, :plugins, :serve_static_assets def initialize(root=nil) super() @root = root - @middleware = ActionDispatch::MiddlewareStack.new + @serve_static_assets = true + @middleware = Rails::Configuration::MiddlewareStackProxy.new end def paths diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index 4e6f94c534..96d9bd0da2 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -78,4 +78,4 @@ module Rails end end end -end
\ No newline at end of file +end |