如何在设置环境变量的情况下启动 Rails 服务器? [英] How to start Rails server with environment variables set?

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

问题描述

我有以下命令.我在启动 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?

所以我会这样做

rails s

它会使用该变量自动运行.

and it would run automatically with that variable.

推荐答案

您有多种选择:

  1. .bashrc 文件中声明变量并重新加载.

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

使用 dotenv gem.

Use dotenv gem.

使用 figaro gem.

Use figaro gem.

更多信息@http://www.gotealeaf.com/blog/managing-environment-configuration-variables-in-rails

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

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