We just deployed the Rails 4.0.3 application for production and found that the resource paths generated by stylesheet_link_tag and javascript_link_tag do not have fingerprints. Therefore, instead of a request of type application-c841bd1c82c25bb1de8452d2338479f7.js , the page is just a request for application.js .
RAILS_ENV=production bundle exec rake assets:precompile successfully and generates fingerprints.
The bits from config/environments/production.rb that seem relevant are as follows:
# Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false # Generate digests for assets URLs config.assets.digest = true # Disable Rails static asset server (Apache or nginx will already do this) config.serve_static_assets = false
This works on our own Apache server, not Heroku. I looked around a bit and found similar problems, but none of the troubleshooting steps for them helps. Thanks.
Additional Information
In case this is useful, here is the full content (deleted lines with comments) of our configuration files:
application.rb
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end module Ctrc class Application < Rails::Application config.ceal.application_title = "CTRC Budgeting" config.encoding = "utf-8" config.filter_parameters += [:password] config.active_support.escape_html_entities_in_json = true config.assets.enabled = true config.assets.version = '1.0' config.pmacs_redmine.project_identifier = 'itmat-gcrc' config.app_data_path = '/data/web/apps/itmat/ctrc' config.paperclip_defaults = { path: "/data/web/apps/itmat/ctrc/:attachment/:id/:style/:basename.:extension" } if ENV['RAILS_RELATIVE_URL_ROOT'] config.assets.prefix = ENV['RAILS_RELATIVE_URL_ROOT'] + '/assets' end end end
production.rb
Ctrc::Application.configure do config.cache_classes = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.serve_static_assets = false config.assets.compress = true config.assets.compile = false config.assets.digest = true config.i18n.fallbacks = true config.active_support.deprecation = :notify config.eager_load = true end
I know that the application is working, because if I installed
config.assets.compile = true
in this file, CSS and JavaScript are compiled and requested correctly.
I include these assets on the page as follows:
<%= stylesheet_link_tag "application", media: "all" %> <%= javascript_include_tag "application" %>
but he still creates references to these assets as follows:
<link href="/apps/itmat/ctrc/stylesheets/application.css" media="all" rel="stylesheet"> <script src="/apps/itmat/ctrc/javascripts/application.js"></script>
instead of the fingerprints that I expected to see.