EnvironmentMismatchError - Rails.env 被设置为 "production"

EnvironmentMismatchError - Rails.env being set to "production"

我在检查本地主机时收到 Missingsecret_key_basefor 'production' environment, set this value in config/secrets.yml 错误。这没有意义,因为我应该在开发中。

我在服务器启动时登录了 Rails.env,它显示 development

从那里我尝试了一些数据库的东西:

Database 'my-server_development' already exists

Database 'my-server_test' already exists

ActiveRecord::EnvironmentMismatchError: You are attempting to modify a database that was last run in development environment. You are running in production environment. If you are sure you want to continue, first set the environment using:

bin/rails db:environment:set RAILS_ENV=production

总而言之,我的环境中的一些神秘配置似乎已设置为生产环境。此错误提示我尝试将我的 rails 环境设置为生产环境以匹配它,但我想要的是将神秘的东西更改为开发环境。

如有任何帮助,我们将不胜感激。

好的,明白了。我在我的一个初始化器中有一个拼写错误,并且正在检查我的 Rails 环境,如下所示:

if Rails.env = "production"
  # blahblah do something

这当然是将 Rails.env 设置为 "production"。我在 Rails 启动过程中弄乱了 Pry,我发现 Rails.env 一度返回 "development",稍后返回 "production"

从那里,快速搜索发现了问题。感谢所有花时间看这个的人。我会将标题更新为更能说明问题的内容。