say I've got my rails app on github and am deploying the github repo on heroku.
I've got a situation where I have a simple text file with bunch of words (it is in my github repo). I want to insert these words (using a simple ruby program) into a database. Instead of using the tap command, is it possible in heroku to just run my simple ruby program and insert the words into the database...or maybe just show them on the terminal?
maybe confusing but basically I want to know how to run simple ruby script from heroku command line?
Running the App or bot on Heroku Now in order to turn on/execute our script, we have to open up our app on the Heroku Website, go to Resources, and hit edit on our worker. - Enable both the web and worker, then save. Note: It can take up to two minutes for the script to start running!
Heroku has an “ephemeral” hard drive, this means that you can write files to disk, but those files will not persist after the application is restarted. By default Active Storage uses a :local storage option, which uses the local file system to store any uploaded files.
With Simple File Upload, you can add file uploading to your app with only two lines of code. We provide a prebuilt S3 setup with no javascript required. Simply add class = simple-file-upload to a hidden input.
With cedar, you can run bash:
heroku run bash
Put your ruby script in a bin directory and git push it to Heroku. Now you can execute a shell command in the heroku console.
For example, if your Ruby script is bin/foo.rb, you can run the following command in the Heroku console:
`ruby bin/foo.rb`
Note the use of backticks.
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