Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 Asset pipeline - Why my images do not precompile for production?

When running:

rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

Everything precompiles but not my /app/assets/images/*

I even tried adding this to my environment/production.rb

config.assets.paths << "#{Rails.root}/app/assets/images"

What's wrong? thanks!

like image 446
Kieran Klaassen Avatar asked Nov 08 '11 15:11

Kieran Klaassen


People also ask

How do you Precompile assets Rails in production?

We use rake assets:precompile to precompile our assets before pushing code to production. This command precompiles assets and places them under the public/assets directory in our Rails application. Let's begin our journey by looking at the internals of the Rails Asset Pipeline. This article is based on Rails 3.2.

What is asset Precompile in Rails?

The Rails asset pipeline provides an assets:precompile rake task to allow assets to be compiled and cached up front rather than compiled every time the app boots. There are two ways you can use the asset pipeline on Heroku. Compiling assets locally. Compiling assets during slug compilation.

What does rake assets Clean do?

The clean it removes the old versions of the precompiled assets while leaving the new assets in place. Show activity on this post. rake assets:clean removes compiled assets. It is run by cap deploy:assets:clean to remove compiled assets, generally from a remote server.


2 Answers

Found a solution: Add to environment/production.rb

config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif] 

Why isn't this default ;ike this line says: (application.js, application.css, and all non-JS/CSS are already added)

like image 167
Kieran Klaassen Avatar answered Oct 08 '22 15:10

Kieran Klaassen


Use this format for the server:

rails assets:precompile:all -e production
like image 25
Michael Durrant Avatar answered Oct 08 '22 15:10

Michael Durrant