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: 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

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