How to build task 'assets:precompile' How to build task 'assets:precompile' ruby-on-rails ruby-on-rails

How to build task 'assets:precompile'


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'


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'


I think that it might be because you aren't requiring the asset gems in production. By default rails expects that you are pre-compiling your assets in production. Change this in config/application.rb:

Comment out this line:

Bundler.require *Rails.groups(:assets => %w(development test))

And uncomment this line:

Bundler.require(:default, :assets, Rails.env)