考虑以下场景:
def connect
self.current_user = find_verified_user
logger.add_tags "ActionCable", "User #{current_user.id}"
end
2) 建立连接后,通知用户
connected: ->
$("body").append("<div class='connection ok'>Connected.</div>")
3) 当连接丢失时,通知用户
disconnected: ->
$("pop-up").append("<div class='connection'>Offline, trying to reconnect...</div>")
4) 当用户注销时。。。。。
An unauthorized connection attempt was rejected
###User is now informed connection is lost. Which should not happen.
如何更改:
mount ActionCable.server => '/cable'
authenticated :user do
root 'users#index', as: :authenticated_root
end