0
votes

I have an old Rails 3 app I'm upgrading to Rails 4. Sprockets seems to be adding suffixes and working with the Javascript I have in /vendor, but my assets/javascripts/application.js, assets/stylesheets/application.css, and assets/images/... aren't working. In the HTML, I can see they have suffixes, but they error when trying to load.

For example, this works: 0.0.0.0:8080/assets/jquery-1.8.3.min-95a3734fc817813c8ba0cd3438033917a3863503b2ca20e8b30a7f61b031576f.js

But this doesn't: 0.0.0.0:8080/assets/application-7437324e57ae6cb54f03eaa608a99381fca68ad72ed2009f8fccd49f41f34bac.css

However, this works: 0.0.0.0:8080/assets/application.css

Images also don't work. When I do image_tag it gives Sprockets::Rails::Helper::AssetNotPrecompiled error.

Should Rails 4 be adding suffixes when in local development mode?

If yes, what's the problem with Rails 4 and Sprockets - do I need to change my config somehow?

1

1 Answers

0
votes

Those "suffixes" are hashes and meant to be unique to the contents of the file. Mostly this is useful in production as a caching technique. It's been a long time since I moved apps from 3 to 4. Modern rails apps are using webpack for a lot of this, but the asset pipeline still works for now.

My recollection is that the hashes weren't being generated in development mode. You should read the documentation on precompiling assets if you haven't already.