Consider the following scenario:
1) WebSocket authenticates the connection.
def connect
self.current_user = find_verified_user
logger.add_tags "ActionCable", "User #{current_user.id}"
end
2) When connection is established, inform the user
connected: ->
$("body").append("<div class='connection ok'>Connected.</div>")
3) When connection is lost, inform the user
disconnected: ->
$("pop-up").append("<div class='connection'>Offline, trying to reconnect...</div>")
4) When user logs out.....
An unauthorized connection attempt was rejected
###User is now informed connection is lost. Which should not happen.
My question: How can I change:
mount ActionCable.server => '/cable'
To only work within the scope of:
authenticated :user do
root 'users#index', as: :authenticated_root
end