sinatra - 使用 config_file 对不同环境做配置

访问量: 190

参考:  http://sinatrarb.com/contrib/config_file

app.rb

require 'sinatra/config_file'
config_file './config/config.yml'
$redis = Redis.new url: settings.redis_url

config/config.yml

development:
  redis_url: 'redis://localhost:6379/1'

production:
  redis_url: 'redis://localhost:6379/1'

test:
  redis_url: 'redis://localhost:6379/2'

订阅/RSS Feed

Subscribe

分类/category