Is it possible to set ENV variables for rails development environment in my code?

后端 未结 7 1191
心在旅途
心在旅途 2020-11-27 09:59

I know that I can set my ENV variables in bash via

export admin_password = \"secret\"

But is there a way to do it in my rails source code s

7条回答
  •  时光取名叫无心
    2020-11-27 10:19

    The system environment and rails' environment are different things. ENV let's you work with the rails' environment, but if what you want to do is to change the system's environment in runtime you can just surround the command with backticks.

    # ruby code
    `export admin_password="secret"`
    # more ruby code
    

提交回复
热议问题