1
votes

In my Rails 3.2.1 application I am using compass(0.12.alpha.4) to create sprites:

@import compass

@import "../images/category-icons/type/*.png"
@include all-type-sprites
//+all-type-sprites

The sprite image was genereated correctly, sitting in app/assets/images/category-icons/type-sa69c4767de.png

However the stylesheet generated is wrong. It points to /assets/../images/category-icons/type-sa69c4767de.png. It merely appends assets to the path. It works outside of Rails, so I think it has something to do with asset pipeline. What should I configure for this to work properly?

1
What do you have in your compass config.rb for http_generated_images_path? I had a similar issue and it was resolved by setting the http config paths. - maxbeatty
I don't see that config at all, and that's not related to this path problem. But thanks for letting me know, as I think it is a good thing to set, so the genereated file can reside outside the asset directory (which annoys for me). - lulalala
I agree. Moving the generated sprite sheet outside app/assets means I don't have to try to exclude those files from version control. Don't forget to add the new path to rails assets paths. generated_images_dir = "tmp/sass-cache/sprites" in config/compass.rb. config.assets.paths += "tmp/sass-cache/sprites" in config/application.rb`. - Matthew Boehlig

1 Answers

5
votes

Are you using compass-rails? It ensures proper integration with the asset pipeline.

Since Compass v0.12, this adapter is the only way to install compass into your rails application.

Don't use a relative path to the source images. Image path references already search through the asset load path. Rails is configured to include app/assets/images in the asset load path by default.

Change the import to:

@import "category-icons/type/*.png"