I used actioncable on rails 5 app. Below code work in controller but not in console.
ActionCable.server.broadcast "connector_app", content: "test message"
Response:
[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 properly):
def sample_socket_message
ActionCable.server.broadcast "connector_app",
content: "test message",
head :ok
end
Problem Solved: Forget to add below code in config/initializer/redis.rb
$redis = Redis.new(:host => 'localhost', :port => 6379)