asymmetric
asymmetric

Reputation: 3890

Asset pipeline not precompiling a required file

I recently added a CSS file to my Rails 3.2 app, and I'm struggling with the asset pipeline. Currently, it says ActionView::Template::Error (pdf.css isn't precompiled).

I've added a = require pdf to my app/assets/stylesheets/application.css file.

What else is necessary?

Do I have to add pdf.css to config.assets.precompile?

If so, why? Shouldn't the require take care of it?

My application.css:

/*
*= require_self
*= require chosen
*= require pdf
*= require_tree ./screen
*/

Upvotes: 3

Views: 1843

Answers (4)

Ben
Ben

Reputation: 13635

Are you requiring pdf.css explicitly somewhere in your html templates?

As explained in the official guide to the asset pipeline, every file you require explicitly in the html (outside of the manifest files) needs to be compiled by adding them to config.assets.precompile.

Upvotes: 3

Mab879
Mab879

Reputation: 608

You need to add pdf.css to config.assets.precompile in your config/environments/production.rb.

The reason for this that rails assumes that you want all your styles in one place.

This also saves space on precompile.

Example: The following files:

  • pdf.css
  • screen.css
  • print.css

would then all compile into application.css.

Upvotes: -1

Andreas Lyngstad
Andreas Lyngstad

Reputation: 4927

There is probably an error (typo) in the pdf.css file. See if you can find any missing semi colons or brackets.

Upvotes: 0

Raindal
Raindal

Reputation: 3237

Try writing in your application.css (btw isn't it supposed to be application.css.scss ?) :

*= require_tree .

This should compile all the stylesheets.

Maybe you could also try a :

rake assets:precompile

It will generate the precompiled stylesheet in your public folder (well, if I'm right...). You can then know if your file is included in the process. (don't forget to delete the compiled stylesheet in development, else the browser would always load this one and none of the changes you would make after)

Upvotes: 0

Related Questions