0

I have a rails application and try to deploy it to my local apache server now right.

I tried to precompile the css,javascript file though the command rake assets:precompile and no errors came out.

However, I cannot not access the website though localhost properly and I checked the log file of production.

Error :

ActionView::Template::Error (scaffolds.css isn't precompiled): 3: 4: Pragprog Books Online Store 5: 6: <%= stylesheet_link_tag "scaffolds" %> 7: <%= stylesheet_link_tag "depot", :media => "all" %> --> 8: <%= stylesheet_link_tag "pagination" %> 9: app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__1763484413904368549_70243433398420'

It seems that the scaffolds.css cannot be precompiled with the command.

I have changed the config to config.assets.compile = true and my website works. :) But I want to know why the command cannot precompile that css.

2
  • Rails does not try to precompile scaffold.css because you didn't tell him to. Commented Sep 9, 2012 at 14:38
  • Possible duplicate of stackoverflow.com/questions/7510920/… Commented Sep 9, 2012 at 17:41

2 Answers 2

4

Check out these lines in your production.rb (or whatever environment you are using), which are probably still commented out:

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )

Simply use this option to specify additional assets to precompile, for example:

config.assets.precompile += %w( *.js *.scss *.coffee *.css )
Sign up to request clarification or add additional context in comments.

2 Comments

But which approach is better?
In production, it's better to precompile your assets since that way they can be served as static assets by the web server (as opposed to the app server). This speeds up things considerably. If you use config.assets.compile = true, the assets are compiled (or in the case of CSS, served) on the fly by the app server, which is slower.
1

Out of curiousity did you add it to your application.css manifest file?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.