aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-12-19 14:16:29 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2014-12-19 14:55:34 -0800
commit2d04bdd86fb4a9c69e1ca1ffe92188a9ca4f88c8 (patch)
tree842f600e072f0ed0b13062a82f36cb7be6129433 /railties/lib/rails/application
parent352680c1d394a2177437f20673ede0753d651913 (diff)
downloadrails-2d04bdd86fb4a9c69e1ca1ffe92188a9ca4f88c8.tar.gz
rails-2d04bdd86fb4a9c69e1ca1ffe92188a9ca4f88c8.tar.bz2
rails-2d04bdd86fb4a9c69e1ca1ffe92188a9ca4f88c8.zip
Merge pull request #18100 from chancancode/serve_static_files
Allow static asset serving from env variable (enhanced!) Conflicts: railties/CHANGELOG.md
Diffstat (limited to 'railties/lib/rails/application')
-rw-r--r--railties/lib/rails/application/configuration.rb25
-rw-r--r--railties/lib/rails/application/default_middleware_stack.rb2
2 files changed, 24 insertions, 3 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 268ef2c7aa..fdc741dd08 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -1,5 +1,7 @@
require 'active_support/core_ext/kernel/reporting'
+require 'active_support/core_ext/string/filters'
require 'active_support/file_update_checker'
+require 'active_support/deprecation'
require 'rails/engine/configuration'
require 'rails/source_annotation_extractor'
@@ -11,7 +13,7 @@ module Rails
:eager_load, :exceptions_app, :file_watcher, :filter_parameters,
:force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
:railties_order, :relative_url_root, :secret_key_base, :secret_token,
- :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
+ :serve_static_files, :ssl_options, :static_cache_control, :session_options,
:time_zone, :reload_classes_only_on_change,
:beginning_of_week, :filter_redirect, :x
@@ -25,7 +27,7 @@ module Rails
@filter_parameters = []
@filter_redirect = []
@helpers_paths = []
- @serve_static_assets = true
+ @serve_static_files = true
@static_cache_control = nil
@force_ssl = false
@ssl_options = {}
@@ -139,6 +141,25 @@ module Rails
self.generators.colorize_logging = val
end
+ # :nodoc:
+ SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE = <<-MSG.squish
+ The configuration option `config.serve_static_assets` has been renamed
+ to `config.serve_static_files` to clarify its role (it merely enables
+ serving everything in the `public` folder and is unrelated to the asset
+ pipeline). The `serve_static_assets` alias will be removed in Rails 5.0.
+ Please migrate your configuration files accordingly.
+ MSG
+
+ def serve_static_assets
+ ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
+ serve_static_files
+ end
+
+ def serve_static_assets=(value)
+ ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
+ self.serve_static_files = value
+ end
+
def session_store(*args)
if args.empty?
case @session_store
diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb
index d1789192ef..02eea82b0c 100644
--- a/railties/lib/rails/application/default_middleware_stack.rb
+++ b/railties/lib/rails/application/default_middleware_stack.rb
@@ -17,7 +17,7 @@ module Rails
middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
- if config.serve_static_assets
+ if config.serve_static_files
middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control
end