I have the following command. I insert it on starting the rails server
我有以下命令。我在启动rails服务器时插入它。
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.
它会自动运行这个变量。
3 个解决方案
#1
0
You have various options to do so:
你有多种选择:
-
Declare your variables in
.bashrc
file and reload it.在.bashrc文件中声明变量并重新加载它。
-
Use
dotenv
gem.使用dotenv宝石。
-
Use
figaro
gem.使用费加罗的宝石。
More info @ http://www.gotealeaf.com/blog/managing-environment-configuration-variables-in-rails
更多信息@ http://www.gotealeaf.com/blog/managing-environment-configuration-variables-in-rails
#2
2
Bundle the dotenv-rails gem, then create a .env
file with the content:
捆绑dotenv-rails gem,然后创建一个.env文件,内容如下:
VARIABLE=development
The gem picks up all variables from the file and sets them in your environment.
gem从文件中获取所有变量并在您的环境中设置它们。
#3
0
If you don't need the variable to be variating, you should put this into initializers or on a helper class. If you're looking for enviroment, you don't need it because it's the default.
如果不需要变量进行变分,应该将其放入初始化器或helper类中。如果你在寻找环境,你不需要它,因为它是默认的。
#1
0
You have various options to do so:
你有多种选择:
-
Declare your variables in
.bashrc
file and reload it.在.bashrc文件中声明变量并重新加载它。
-
Use
dotenv
gem.使用dotenv宝石。
-
Use
figaro
gem.使用费加罗的宝石。
More info @ http://www.gotealeaf.com/blog/managing-environment-configuration-variables-in-rails
更多信息@ http://www.gotealeaf.com/blog/managing-environment-configuration-variables-in-rails
#2
2
Bundle the dotenv-rails gem, then create a .env
file with the content:
捆绑dotenv-rails gem,然后创建一个.env文件,内容如下:
VARIABLE=development
The gem picks up all variables from the file and sets them in your environment.
gem从文件中获取所有变量并在您的环境中设置它们。
#3
0
If you don't need the variable to be variating, you should put this into initializers or on a helper class. If you're looking for enviroment, you don't need it because it's the default.
如果不需要变量进行变分,应该将其放入初始化器或helper类中。如果你在寻找环境,你不需要它,因为它是默认的。