Run Rails commands outside of console

✔ Recommended Answer

There are two main ways to run commands outside console:

  1. Rake task which depends on :environment

  2. rails runner (previously script/runner), eg:

    $ rails runner "query"

Both are pretty well documented on the rails guide:

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.


Answered By: Tim Peters


Most Popular

Remove Unicode Zero Width Space PHP

PhpStorm, return value is expected to be 'A', 'object' returned

Laravel file upload returns forbidden 403, file permission is 700 not 755