http://guides.rubyonrails.org/configuring.html#custom-configuration
(1)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
(2)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.10x.xx.xx'
+ config.x.redis.port = 6379
end
(3)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
(4)config/environments/staging.rb
# Based on production defaults
require Rails.root.join("config/environments/production")
+
+Rails.application.configure do
+ config.x.redis.host = '10.10x.xx.xx'
+ config.x.redis.port = 6379
+end
+redis_config = Rails.configuration.x.redis
+Redis.current = Redis.new(:host => redis_config.host, :port => redis_config.port)