Asset pipeline in production with Rails 7.0.0.alpha

Viewed 276

Hey everyone this one has left me somewhat stumped and I feel like I have been going around in circles. I am trying to get my assets to be served from a CDN (in this case AWS/Cloudfront)

The assets are precompiled and deployed to the S3 bucket via CI server and that is working fine.

I have read the guides and believe I have set the config/environments/production.rb correcting as follows:

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
# config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
config.asset_host = ENV['RAILS_ASSET_HOST']

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

I have debugged that the environment variable RAILS_ASSET_HOST is set correctly to https://asset.mycdn.com but no matter what I do I continue to get the following error:

ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.

Any help appreciated. I am sure it is something stupid, just been staring too long!

1 Answers

From recollection, you need to have the generated manifest file on the app server, otherwise rails has no way of translating application.css into the corresponding application-SOME_SHA.css

Related