I switched my server to production and i cannot get any of my images to load. It all works fine on development mode but when i switched to production it all stopped working i have enabled server_static_assets and still yet nothing works. Any help towards doing this
-
even image_tag is not working – Uchenna Sep 07 '11 at 21:23
-
i can see this in my server log `cache: [GET /assets/icon_thumb.png] stale, valid, store` – Uchenna Sep 07 '11 at 21:31
3 Answers
Here are a few problems that you might be having:
1 - Your production configuration may not be correct. This is particularly likely if you started out with an early 3.1 release candidate, and have been updating along the way. The suggested options for production.rb changed quite a bit between rc4 and the 3.1.0 release.
Make sure that your production.rb settings include:
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# 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
2 - You may have forgotten to precompile your assets
RAILS_ENV=production rake assets:precompile
3 - You may have forgotten to restart your web server to pick up the changes in production.rb.

- 8,332
- 5
- 41
- 49
If you are upgrading to Rails 4 or are currently using it on production, and are loading images from css, then:
instead of
background-image: url('some_image.jpg');
do
background-image: image-url('some_image.jpg');
See http://guides.rubyonrails.org/asset_pipeline.html#css-and-sass for reference
Remember to run rake assets:precompile
in your production environment.
If you need are deploying with Capistrano, you can use this recipe:
before "deploy:symlink", "assets:precompile"
namespace :assets do
desc "Compile assets"
task :precompile, :roles => :app do
run "cd #{release_path} && rake RAILS_ENV=#{rails_env} assets:precompile"
end
end

- 1,848
- 20
- 21