For Rails, how to access or print out config variables (as experiment or test / debugging)

后端 未结 3 1149
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 06:18

For example, in config/environments/production.rb in a Rails 3 app, there is

config.serve_static_assets = false

and many variables

3条回答
  •  逝去的感伤
    2021-02-02 06:43

    Like idlefingers pointed out, for newer versions of rails, Rails.application.config.my_variable should get you what you're looking for.

    However, if that doesn't work because you're stuck with an older version of Rails (2.3, etc) you can use the ENV constant, like so: ENV['my_variable']

提交回复
热议问题