如何在开发环境和生产环境中定义不同的变量?
比如远程服务器和端口号,来回更改真的很烦人,我注意到有一个
set :environment, :production/:development
sinatra 的配置选项,但我不知道如何为每种模式设置不同的变量
like the remote server and port number, It's really annoying to change back and forth, I noticed there's a
set :environment, :production/:development
configuration option for sinatra, but I don't know how to set different variable to each mode
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以有这样的东西:
you can have something like this:
如果您的设置很少:
对于经典 Sinatra 应用程序:
对于模块化 Sinatra 应用程序:
但如果您有多个与环境相关的设置,则使用上面的三个建议会更干净:
If your settings are few:
For classic Sinatra apps:
For modular Sinatra apps:
But if you have several environment dependent settings, using three's suggestion above is cleaner: