Skip to content

Commit

Permalink
Support Rails 5 static file serving configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnall authored and seanpdoyle committed Oct 24, 2016
1 parent c956653 commit c2bdeb9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
master
------

* Support Rails 5 static file serving configuration. [#499]

[#499]: https://github.com/thoughtbot/ember-cli-rails/pull/499

0.8.1
-----

Expand Down
18 changes: 15 additions & 3 deletions lib/ember_cli/deploy/file.rb
Expand Up @@ -29,9 +29,21 @@ def index_html
attr_reader :app

def rack_headers
{
"Cache-Control" => Rails.configuration.static_cache_control,
}
config = Rails.configuration

if config.respond_to?(:public_file_server) &&
config.public_file_server && config.public_file_server.headers
# Rails 5.
config.public_file_server.headers
elsif config.respond_to?(:static_cache_control)
# Rails 4.2 and below.
{
"Cache-Control" => Rails.configuration.static_cache_control,
}
else
# No specification.
{}
end
end

def check_for_error_and_raise!
Expand Down
8 changes: 7 additions & 1 deletion spec/dummy/application.rb
Expand Up @@ -25,7 +25,13 @@ class Application < Rails::Application
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

config.static_cache_control = CACHE_CONTROL_FIVE_MINUTES
if Rails.version >= "5"
config.public_file_server.headers = {
"Cache-Control" => CACHE_CONTROL_FIVE_MINUTES
}
else
config.static_cache_control = CACHE_CONTROL_FIVE_MINUTES
end

config.secret_token = "SECRET_TOKEN_IS_MIN_30_CHARS_LONG"
config.secret_key_base = "SECRET_KEY_BASE"
Expand Down

0 comments on commit c2bdeb9

Please sign in to comment.