How do I access a Rails configuration value during runtime? -
i'm using rails 2.3.x. small section of code run if , if config.cache_classes
true. default, that's true production , false development.
how access value of config.cache_classes outside of environment.rb, development.rb, , production.rb files? it's easy tell if in production or development, rails.env
give answer. there's no guarantee developer hasn't set config.cache_classes = true
in development.
i understand not want run separate code paths in development , production. in particular instance, not performing work on startup; if need perform later, so, both in development , production.
for rails 2, can do:
rails.configuration.cache_classes
if ever switch rails 3, it'll different; can access same value with:
rails.application.config.cache_classes
Comments
Post a Comment