Joe
Joe

Reputation: 369

Static files not found after Rails app deployed to heroku

I'm fairly new to the whole asset pipeline concept, I put the third party js file (as well as the css and image files) in the vendor/assets folder, allow me to give a quick example how I did it:

where the file is stored: vendor/assets/javascript/plugins/isotope/isotope.pkgd.min.js

how it's referenced in the application.js: //= require plugins/isotope/isotope.pkgd.min

and how it's referenced in the index.html.erb <script src="/assets/plugins/isotope/isotope.pkgd.min.js"></script>

it works just fine locally, but after I deployed the app onto heroku, I got http://myapp.herokuapp.com/assets/plugins/isotope/isotope.pkgd.min.js not found error, without it, my app does not work...I kinda know part of the asset pipeline's job is to compress all the js files (the ones referenced in the application.js) into one single js file, does not mean I will need to refer isotope.pkgd.min.js differently in my html.erb?

Upvotes: 0

Views: 561

Answers (1)

Elvn
Elvn

Reputation: 3057

There are several steps in debugging an asset pipeline problem. You didn't mention you'd done an asset pre-compilation before deploy. Heroku does not compile assets upon deploy automatically. Here's their text on the matter

If a public/assets/manifest.yml is detected in your app, Heroku will assume you are handling asset compilation yourself and will not attempt to compile your assets. Rails 4 uses a file called public/assets/manifest-.json instead. On both versions you can generate this file by running $ rake assets:precompile locally and checking the resultant files into Git.

https://devcenter.heroku.com/articles/rails-asset-pipeline

A simple test would be to precompile your assets (and git checkin, if you're using git push Heroku) before Heroku deploy and see if that doesn't resolve the issue.

On your dev platform:

bundle rake exec assets:precompile RAILS_ENV=production

Upvotes: 1

Related Questions