Rails 3 控制台始终在测试环境中启动
我的 Rails 3 应用程序总是卡在测试环境中。当我调用
rake db:reset
它时,它会重置测试数据库,但不会重置开发数据库。
当我运行以下代码时,它在控制台中加载测试环境:
rails c
尝试指定开发环境也不起作用:
jon@jon-laptop:~/id$ RAILS_ENV=development rails console
Loading test environment (Rails 3.0.8)
ruby-1.8.7-p334 :001 >
启动服务器确实可以正常工作:
rails s
这非常烦人。关于我应该在哪里解决这个问题有什么想法吗?
预先感谢,
编辑
我还尝试回顾历史以在问题存在之前更早地提交(我认为)并且它不能解决问题......
My rails 3 app always is stuck in the Test environment. When I call
rake db:reset
it resets the test database, but not the development one.
When I run the following code, it loads the test environment in the console:
rails c
Trying to specify the development environment also does not work:
jon@jon-laptop:~/id$ RAILS_ENV=development rails console
Loading test environment (Rails 3.0.8)
ruby-1.8.7-p334 :001 >
Starting the server does work normally:
rails s
This is very annoying. Any ideas on where I should look to resolve this?
Thanks in advance,
EDIT
I also tried going back in history to earlier commit to before the problem existed (I think) and it does not fix the problem...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是设置环境可能是使用 RAILS_ENV 环境变量,例如:
编辑:您使用的是哪个版本的 Rails?这对我来说在 3.0.7 上工作得很好:
例如
The easiest way is to set the environment is probably by using the RAILS_ENV environment variable, e.g.:
Edit: Which version of Rails are you using? This works fine for me on 3.0.7:
E.g.
我发现了问题。我的初始化程序之一中有以下几行:
你能发现错误吗???
I found the problem. I had the following lines in one of my initializers:
Can you spot the mistake???