I have a Rails 4 app. One of my javascript assets uses ruby to get all Users.
A problem arises when I try to upload to heroku. It says that it cannot precompile that asset because the database does not yet exist. What can I do short of removing that asset, uploading to heroku to migrate the database, and then putting it back?
Thanks!
Compile assets locally
To solve this chicken and egg problem with the database in deploy, do not invoke precompile in production, precompile on development machine for production prior to push. With a functional code base pushed, you can run "$heroku db:xxx" commands on Heroku.
On deploy to Heroku, you're looking for this line:
I think these steps will solve your problem. Please let me know.
Caveat
Once you disable precompile, you will have to remember to always precompile for production on your dev system prior to deploy to production.
Javascript compilation into asset pipeline
Since you're specifically speaking of js precompile, And I haven't tried this, but it seems these types of precompile js-specific lines should also be commented out in production.rb if you have them. There are the same type of js directives in assets. rb, again I don't know if these need to be cleared or not. (The main point is to do a local asset precompile, before the push to Heroku.)
Heroku docs
https://devcenter.heroku.com/articles/rails-asset-pipeline#compiling-assets-locally