是否有任何理由不在Heroku上使用RAILS

编程入门 行业动态 更新时间:2024-10-25 00:24:40
本文介绍了是否有任何理由不在Heroku上使用RAILS_ENV = staging?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

位于 devcenter.heroku /articles/deploying-to-a-custom-rails-environment 说,我不应该使用staging.rb文件来定义我的暂存环境.

The Heroku documentation at devcenter.heroku/articles/deploying-to-a-custom-rails-environment says I shouldn't use a staging.rb file to define my staging environment.

创建另一个自定义环境(例如"staging")并创建config/environments/staging.rb并使用RAILS_ENV = staging部署到Heroku应用程序可能很诱人.

It may be tempting to create another custom environment such as "staging" and create a config/environments/staging.rb and deploy to a Heroku app with RAILS_ENV=staging.

这不是一个好习惯.相反,我们建议始终在生产模式下运行,并通过设置config vars来修改任何行为.

This is not a good practice. Instead we recommend always running in production mode and modifying any behavior by setting your config vars.

我认为这是一个糟糕的建议,并且与公认的Rails最佳实践相冲突.但是,我不是在这里讨论最佳实践.我在这里问:

I think this is terrible advice and conflicts with well-established Rails best practice. However, I'm not here to argue about best practices. I'm here to ask:

是否有任何理由不在Heroku上使用RAILS_ENV = staging?

Are there any reasons not to use RAILS_ENV=staging on Heroku?

如果我创建一个staging.rb文件并像这样设置xxx_ENV配置变量,是否有任何东西会损坏?

Is there anything that will break if I create a staging.rb file and set the xxx_ENV config vars like this?

heroku config:add RACK_ENV=staging --remote staging heroku config:add RAILS_ENV=staging --remote staging

推荐答案

不,如果执行此操作,不会破坏任何内容.

No, there isn't anything that will break if you do this.

但是,我确实认为Heroku就在这里(请注意,我在Heroku工作). 当阶段环境和生产环境之间唯一改变的地方应该是配置变量时,它介绍了阶段环境和生产环境之间可能存在的差异. Heroku已经提供了使用config:set命令设置配置变量的安全方法. 使用2个配置文件意味着您必须维护相同的配置两次,并且可能会出现问题,因为您在阶段中正确地更新了配置,但是在生产中错误地更新了该配置.

However, I do think that Heroku is right here (note that I work at Heroku). It introduces possible differences between your staging and production environments, when the only thing that changes between them should be configuration variables. Heroku already provides a secure mean of setting configuration variables, with the config:set command. Using 2 config files means you have to maintain the same configuration twice, and possible can have issues because you updated the configuration correctly in staging, but incorrectly in production.

请注意,RACK_ENV只能有3个值:production,development和none.参见 www.hezmatt/~mpalmer/blog/2013/10/13/rack_env-its-not-for-you.html

As a side note, RACK_ENV should only ever have 3 values: production, development and none. See www.hezmatt/~mpalmer/blog/2013/10/13/rack_env-its-not-for-you.html

更多推荐

是否有任何理由不在Heroku上使用RAILS

本文发布于:2023-10-28 13:26:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有任何   理由   RAILS   Heroku

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!