Reputation: 3890
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
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
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:
would then all compile into application.css
.
Upvotes: -1
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
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