rails 下自定义配置变量

APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]

#rails3
MyApp::Application.config.custom_config_variable = :my_config_setting
or

Rails.configuration.custom_config_variable = :my_config_setting
#need initialization files or the environment.rb
YourApp::Application.configure do
  config.something = foo
  config.....
  config....
  .
  config....
end


defaults: &defaults
  audiocast_uri_format: http://blablalba/blabbitybla/yadda

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults


APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]


uri_format = APP_CONFIG['audiocast_uri_format']


APP_CONFIG = YAML.load(ERB.new(File.new(File.expand_path('../config.yml', __FILE__)).read).result)[Rails.env]

你可能感兴趣的:(Ruby,Rails,app_config)