From 3ff39494cdea67502dbd6465358eca3e14a84d6b Mon Sep 17 00:00:00 2001 From: Eliot Sykes Date: Mon, 4 May 2015 20:55:23 +0100 Subject: config.static_index configures directory index "index.html" filename Set `config.static_index` to serve a static directory index file not named `index`. For example, to serve `main.html` instead of `index.html` for directory requests, set `config.static_index` to `"main"`. --- railties/lib/rails/application/configuration.rb | 5 +++-- railties/lib/rails/application/default_middleware_stack.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index dc3ec4274b..78a47fcda9 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -11,8 +11,8 @@ 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_files, :ssl_options, :static_cache_control, :session_options, - :time_zone, :reload_classes_only_on_change, + :serve_static_files, :ssl_options, :static_cache_control, :static_index, + :session_options, :time_zone, :reload_classes_only_on_change, :beginning_of_week, :filter_redirect, :x attr_writer :log_level @@ -28,6 +28,7 @@ module Rails @helpers_paths = [] @serve_static_files = true @static_cache_control = nil + @static_index = "index" @force_ssl = false @ssl_options = {} @session_store = :cookie_store diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb index 02eea82b0c..503977b395 100644 --- a/railties/lib/rails/application/default_middleware_stack.rb +++ b/railties/lib/rails/application/default_middleware_stack.rb @@ -18,7 +18,7 @@ module Rails middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header if config.serve_static_files - middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control + middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control, config.static_index end if rack_cache = load_rack_cache -- cgit v1.2.3