Skip to content

Commit

Permalink
Removing static_files warnings in Rails 5
Browse files Browse the repository at this point in the history
Issue #19
  • Loading branch information
brenes committed Jun 7, 2016
1 parent f865a92 commit d4d9879
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
23 changes: 22 additions & 1 deletion app/models/no_cms/blocks/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,28 @@ def fields_configuration
##
# If we don't have a globalized model yet we return our temporary layout
def layout
globalized_model.nil? ? @layout : globalized_model.layout
# Since respond_to_missing? has been reimplemented in
# NoCms::Blocks::Concerns::SerializingFields we need to first check that
# we have the foreign key to access the globalized_model association
#
# This is due to the empty translations Globalize creates sometimes that
# only have locale.
#
# If we don't check then we will throw a non defined attribute
# exception.

# First we check wether we don't respond to the foreign key of the
# globalize model association
if !respond_to?(self.class.reflections.symbolize_keys[:globalized_model].foreign_key) ||
globalized_model.nil? # and then that the globalized model is nil

# In any of these cases we return our stored layout
@layout
else
# If we can access to the globalized_model, then we return its
# information
globalized_model.layout
end
end

include NoCms::Blocks::Concerns::SerializingFields
Expand Down
9 changes: 7 additions & 2 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
config.eager_load = false

# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
if Rails.version > "5"
config.public_file_server.enabled = true
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
else
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
end

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand Down

0 comments on commit d4d9879

Please sign in to comment.