在 config/initalizers/redis.rb 中链接方式
if Rails.env.production?
$redis = Redis.new(:host =>' XXXX', :password => "XXXX", :port => 6379, db: 2)
else
$redis = Redis.new(:host => 'localhost', :port => 6379, db: 2)
end
出现异常 Redis::CommandError (ERR invalid password):
actioncable 中的 cable.yml 中 redis 配置
development:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: friend_production
test:
adapter: async
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://XXXX:6379" } %>
password: 'XXXXXX'
channel_prefix: friend_production
actioncable 能链接上 redis