I have setup开发者_JAVA技巧 my application configuration for my rails 3.1 application as described here by Ryan Bates.
Problem is I want to use the config in my environment file for username/password for ActionMailer, but Ryan suggests loading the config from an initializer, and they seem to get included after environment.rb. Where is the best place to load the configuration file so it can be accessed by the whole rails application?
Thanks
In that case, this code should go in as a pre-initializer. As of Rails 3, all pre-initialization code needs to go near the top of application.rb, just before the line require 'rails/all'
application.rb:
require File.expand_path('../boot', __FILE__)
# load app_config.yml
require 'yaml'
APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
require 'rails/all'
精彩评论