http://guides.rubyonrails.org/configuring.html#custom-configuration
config/application.rb
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s] config.i18n.default_locale = :"zh-CN"++ # Rails 自定义配置+ # http://guides.rubyonrails.org/configuring.html#custom-configuration + config.x.redis.host = '127.0.0.1'+ config.x.redis.port = 6379 end end
config/environments/production.rb
# Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new++ config.x.redis.host = '10.103.xx.xx'+ config.x.redis.port = 6379 end
config/environments/staging.rb
# Based on production defaults require Rails.root.join("config/environments/production")++Rails.application.configure do+ config.x.redis.host = '10.103.xx.xx'+ config.x.redis.port = 6379+end
config/initializers/redis.rb
+redis_config = Rails.configuration.x.redis+Redis.current = Redis.new(:host => redis_config.host, :port => redis_config.port)