I used actioncable in rails 5 app. Below code works in the controller, but not in the console.
ActionCable.server.broadcast "connector_app", content: "test message"
Answer:
[ActionCable] Broadcasting to connector_app: {:content=>"test message"}
=> nil
cable.yml
development:
adapter: redis
url: redis://localhost:6379/1
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1
Contoller code (it works correctly):
def sample_socket_message
ActionCable.server.broadcast "connector_app",
content: "test message",
head :ok
end
Solution: Forget adding below code in config / initializer / redis.rb
$redis = Redis.new(:host => 'localhost', :port => 6379)
source
share