[英]Rails always using production environment
I'm having an issue where no matter what environment I try to run Rails in it always goes to production. 我遇到一个问题,无论我尝试在其中运行Rails的哪种环境始终将其投入生产。 For example:
例如:
$ rails c development
Loading production environment (Rails 3.2.16)
1.9.3p484 :001 >
$ RAILS_ENV=development rails console
Loading production environment (Rails 3.2.16)
1.9.3p484 :001 >
I first noticed this when I was running the Rails server and it was writing to the production database instead of development. 我在运行Rails服务器时首先注意到了这一点,它正在写入生产数据库而不是开发数据库。 If I run "rails s -e development" it says it starts up in development but still uses the production database.
如果我运行“ rails s -e开发”,则表示它在开发中启动,但仍使用生产数据库。
Here's my config/environment.rb 这是我的config / environment.rb
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Skeletor::Application.initialize!
I tried grepping through the project to see if RAILS_ENV was being set anywhere but I don't see it. 我尝试在项目中进行grepping,以查看是否将RAILS_ENV设置在任何地方,但我没有看到。
尝试运行:
RAILS_ENV=development bundle exec rails s
In an initializer I had done "if Rails.env = 'production'" instead of "if Rails.env == 'production'" which was causing the problem. 在初始化程序中,我执行了“ if Rails.env ='production'”而不是“ if Rails.env =='production'”,这引起了问题。 Thanks for the suggestions everyone, I knew it had to be something silly.
感谢大家的建议,我知道这一定很愚蠢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.