Run Rails commands outside of console
✔ Recommended Answer
There are two main ways to run commands outside console:
Rake task which depends on :environment
rails runner (previously script/runner), eg:
$ rails runner "query"
Both are pretty well documented on the rails guide: https://guides.rubyonrails.org/command_line.html#bin-rails-runner
btw: both of these methods will still take the same time as a console to fire up, but they are useful for non-interative tasks.
Source: stackoverflow.com
Answered By: Tim Peters
Comments
Post a Comment