如何启动带有环境变量的Rails服务器? [英] How to start Rails server with environment variables set?

查看:165
本文介绍了如何启动带有环境变量的Rails服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下命令。我在启动 rails server时插入它

  VARIABLE = 

如何让这个变量自动启动,而不必每次都自动转发?



所以我会这样做

  rails s 

,它将自动运行该变量。

解决方案

您有多种选择:


  1. .bashrc 文件并重新加载。


  2. 使用 dotenv 宝石。


  3. 使用


更多信息@ HTTP://www.gotealeaf.c om / blog / manage-environment-configuration-variables-in-rails


I have the following command. I insert it on starting the rails server

VARIABLE=development rails s

How do I make this variable start automatically, without having to wright it myself every time?

So I would then just do this

rails s

and it would run automatically with that variable.

解决方案

You have various options to do so:

  1. Declare your variables in .bashrc file and reload it.

  2. Use dotenv gem.

  3. Use figaro gem.

More info @ http://www.gotealeaf.com/blog/managing-environment-configuration-variables-in-rails

这篇关于如何启动带有环境变量的Rails服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆