ITeye博客

rails 下自定义配置变量

夜鸣猪 · 2012-10-18 07:36 · Ruby On Rails · 编程语言 · Markdown


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]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。