ruby - Accessing config from application.rb in Controller (Rails 3) - Stack Overflow:
I believe you've got a slightly incorrect idea behind what your expectations for the config/application.rb is providing you. The ActiveRecord::Base and ActiveController::Base eigenclasses use the Rails::Application::Configuration class that is configured in config/application.rb. The attributes aren't available in classes that descend from either of the Base classes, nor their eigenclasses. This is why you are running into errors in ApplicationController. There are generally two ways to make configuration initializations in a Rails app. The first way is to create a configuration module and then load values into it via initializer: First, create a Twiter Config module: #lib/twitter_config.rb module TwitterConfig def config @@config ||= {} end def config=(hash) @@config = hash end end Create a YAML config file: # config/twitter.yaml development: &base key = "foo" secret = "b...
Full article:
http://stackoverflow.com/questions/4143638/accessing-conf...