rodrigoalvesvieira
rodrigoalvesvieira

Reputation: 8062

How to make the asset pipeline process images in subdirectories

I have a Rails app that began as a 3.0.x app and recently was upgraded to 3.2.2. The images are in app/assets/images/ecommerce/new and when I run rake assets:precompile locally they aren't copied to public/assets/. However, when I copied all image files from app/assets/images/ecommerce/new to the root images asset path (that is, app/assets/imagens) and ran the rake task again, the images were all sent to public/assets.

When I run the server locally in production mode it doesn't find the images but when I deploy to Engine Yard, it does. That's very weird, do you know what's happening?

Can't the asset pipeline process images that are inside subdirectories of app/assets/images? Am I missing anything?

Here follows the source of config/environments/production.rb, on what concerns the asset pipeline:

MyApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

config.cache_classes = true

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif] 

# Generate digests for assets URLs
config.assets.digest = true

Upvotes: 1

Views: 637

Answers (1)

Ringo
Ringo

Reputation: 5493

config.assets.compile = true is the problem. This is not doing what you think it should. This actually tells the server to compile on demand. That might explain why you see the files sometimes, and other times you don't.

If you want to add directories, add them to config.assets.paths.

Upvotes: 2

Related Questions