Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build task 'assets:precompile'

I'm getting that error on my production server, and can't figure out why. It happens when running this command:

bundle exec rake assets:precompile RAILS_ENV=production 

I'm using Rails 3.1.0.rc6

like image 839
tybro0103 Avatar asked Aug 26 '11 14:08

tybro0103


People also ask

How do you Precompile an asset?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

How do you Precompile in rails?

This method is responsible for saving assets to disk, and is pretty self-explanatory. Run rake assets:precompile from the command-line from the root of your Rails application. Look at the public/assets directory and you'll see the assets of your Rails application. Our interest at this point is rails.

What does rake assets Clean do?

The clean it removes the old versions of the precompiled assets while leaving the new assets in place. Show activity on this post. rake assets:clean removes compiled assets. It is run by cap deploy:assets:clean to remove compiled assets, generally from a remote server.


2 Answers

This is most likely due your config/application.rb not requiring rails/all (the default), but some custom requires.

To resolve this, add the following to config/application.rb:

require 'sprockets/railtie' 
like image 168
Koraktor Avatar answered Sep 18 '22 18:09

Koraktor


I know this is an old post but I thought it might help someone (probably my future self) if I added this to the answers.

add to Capfile (or deploy.rb)

load 'deploy/assets' 

add this to application.rb

require 'sprockets/railtie' 
like image 41
engineerDave Avatar answered Sep 22 '22 18:09

engineerDave