2007-12-24
Rails宝典八十五式:YAML配置文件
关键字: rails yaml configuration
我们的程序中可能有一些参数配置,我们可以将这些配置放在外部YAML文件里而不必污染应用程序代码:
# config/initializers/load_config.rb
APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]
# application.rb
def authenticate
if APP_CONFIG['perform_authentication']
authenticate_or_request_with_http_basic do |username, password|
username == APP_CONFIG['username'] && password == APP_CONFIG['password']
end
end
end
# config/config.yml
development:
perform_authentication: false
test:
perform_authentication: false
production:
perform_authentication: true
username: admin
password: secret
发表评论
- 浏览: 682508 次
- 性别:

- 来自: BJ

- 详细资料
搜索本博客
我的相册
screenshot
共 1 张
共 1 张
最近加入圈子
最新评论
-
Rails程序开发的最大问题 ...
老刑的建议很好,谢谢 其实打工就是这样,很矛盾,明明自己没什么权力,但又这也看不 ...
-- by hideto -
Rails程序开发的最大问题 ...
liuqiang 写道 刑天战士 写道作为一个和老板战斗了1年多的人,我给你点经 ...
-- by 刑天战士 -
Rails程序开发的最大问题 ...
刑天战士 写道 作为一个和老板战斗了1年多的人,我给你点经验: 1.Don't ...
-- by liuqiang -
Rails程序开发的最大问题 ...
作为一个和老板战斗了1年多的人,我给你点经验: 1.Don't only ma ...
-- by 刑天战士 -
Rails程序开发的最大问题 ...
对,就是缺乏技术负责人这样的角色 我越来越发现,一个项目成员的构成应该是树形结构 ...
-- by hideto






评论排行榜