Upgraded from Rails 3 to 4, and now the image assets aren't showing in production. It appears that the javascript and css files are working ok.
I've tried the steps at https://github.com/capistrano/capistrano/wiki/Upgrading-to-Rails-4 but it doesn't help.
I've tried deleting the json files and yml files in my shared/assets folder, but it still doesn't show the images once the deploy finishes.
If I try to view an image on the site in a new tab, I get the "The page you were looking for doesn't exist." error.
I've tried this:
Bundler.require(:default, Rails.env)
and this:
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
in the config/application.rb file. Neither work.
Here's what I have in my config/environments/production.rb file:
config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.assets.version = '1.0'
The Capfile:
load 'deploy'
load 'deploy/assets'
load 'config/deploy'
What am I doing wrong? How can I get the images to show up in production?
Rails 4 no longer creates assets without a digest. So if you are referencing assets (such as images) directly (e.g. /assets/whatever.jpg) without a digest in the URL, you will likely get a 404.
non-stupid-digest-assets gem will fix this by creating non-digest assets: https://github.com/alexspeller/non-stupid-digest-assets/tree/master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With