Cassio Cabral
Cassio Cabral

Reputation: 2692

How to use sprockets 4 with Rails 5 after upgrade

I've being trying to use Rails 5 after upgrade my Rails 4.2 app.

After change the version I used the command bundle exec rake rails:update

I got the error when I access some view:

Asset `application.css` was not declared to be precompiled in  production.
Declare links to your assets in `assets/config/manifest.js`.

Upvotes: 3

Views: 4767

Answers (1)

Cassio Cabral
Cassio Cabral

Reputation: 2692

Since sprockets 4 requires the manifest.js file you have to create the file assets/config/manifest.js, it was suppose to be created on the generator, but since it was not defined where to put the file, it does not create for now. The location(or type, from js to yml) of the file it might change until Rails 5 release, so be aware.

Add some options like below, suggested by @Eileen from Basecamp:

// JS and CSS bundles
//
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css


// Images and fonts so that views can link to them
//
//= link_tree ../fonts
//= link_tree ../images

Upvotes: 8

Related Questions