Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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