How do I access a Rails configuration value during runtime?

前端 未结 2 1212
情书的邮戳
情书的邮戳 2021-02-02 05:39

I\'m using Rails 2.3.x. I would like a small section of code to run if and only if the config.cache_classes is true. By default, that\'s true for production and f

2条回答
  •  -上瘾入骨i
    2021-02-02 06:06

    For Rails 2, you can do:

    Rails.configuration.cache_classes
    

    If you ever switch to Rails 3, it'll be different; you can access the same value with:

    Rails.application.config.cache_classes
    

提交回复
热议问题