File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 11master
22------
33
4+ * Support Rails 5 static file serving configuration. [ #499 ]
5+
6+ [ #499 ] : https://github.com/thoughtbot/ember-cli-rails/pull/499
7+
480.8.1
59-----
610
Original file line number Diff line number Diff line change @@ -29,9 +29,21 @@ def index_html
2929 attr_reader :app
3030
3131 def rack_headers
32- {
33- "Cache-Control" => Rails . configuration . static_cache_control ,
34- }
32+ config = Rails . configuration
33+
34+ if config . respond_to? ( :public_file_server ) &&
35+ config . public_file_server && config . public_file_server . headers
36+ # Rails 5.
37+ config . public_file_server . headers
38+ elsif config . respond_to? ( :static_cache_control )
39+ # Rails 4.2 and below.
40+ {
41+ "Cache-Control" => Rails . configuration . static_cache_control ,
42+ }
43+ else
44+ # No specification.
45+ { }
46+ end
3547 end
3648
3749 def check_for_error_and_raise!
Original file line number Diff line number Diff line change @@ -25,7 +25,13 @@ class Application < Rails::Application
2525 # Print deprecation notices to the stderr.
2626 config . active_support . deprecation = :stderr
2727
28- config . static_cache_control = CACHE_CONTROL_FIVE_MINUTES
28+ if Rails . version >= "5"
29+ config . public_file_server . headers = {
30+ "Cache-Control" => CACHE_CONTROL_FIVE_MINUTES
31+ }
32+ else
33+ config . static_cache_control = CACHE_CONTROL_FIVE_MINUTES
34+ end
2935
3036 config . secret_token = "SECRET_TOKEN_IS_MIN_30_CHARS_LONG"
3137 config . secret_key_base = "SECRET_KEY_BASE"
You can’t perform that action at this time.
0 commit comments