rails console test loading development environment

元气小坏坏 提交于 2019-12-23 08:44:41

问题


I have a problem where

rails console test

results in

Loading development environment (Rails 3.1.0)

I suspect it's a RAILS_ENV problem because doing

RAILS_ENV=test rails console

results in

Loading test environment (Rails 3.1.0)

Any suggestions? Thanks.


回答1:


Yes, you must specify RAILS_ENV or use rails console [environment].




回答2:


Is environment variable RAILS_ENV already set (in your command line environment)?

Ideally, rails console test should set RAILS_ENV to 'test' and disregard its value in the command line environment.

However, if it is set to something (nonblank) other than 'test', then, obviously, potentially one might see a difference in behavior between rails console test and RAILS_ENV=test rails console.

EDIT: If RAILS_ENV is set to development in my shell environment, and I do rails console test, then I get the test environment, just as Adam Eberlin and Brian also report.

It's still mysterious (to me) what might be different in your setup, or what's causing your observed difference in behavior.

Therefore, you should not accept this (my) answer!



来源:https://stackoverflow.com/questions/7668167/rails-console-test-loading-development-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!