I frequently need to run the command "Rails.cache.clear" on Heroku and the only way I have found to do it is to first run "heroku run console" and then run the command. Any way to do it in one step?
So, the reason why you cannot use SQLite on Heroku is because SQLite stores all database information in a file on disk, and because Heroku will delete the files on your disk, this won't work.
Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .
This seems to work:
echo "Rails.cache.clear; exit" | heroku run console
Without the exit it seems to hang for some reason, at least for me.
I think this is what you're looking for:
heroku run rails runner -e production Rails.cache.clear
If you don't set the environment, development will be used.
If it's a common task like clearing the cache, make a rake task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With