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: http://guides.rubyonrails.org/command_line.html
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…