Chanha Lee

Joined

1,120 Experience
11 Lessons Completed
0 Questions Solved

Activity

Posted in Group Chat with ActionCable: Part 5 Discussion

please help me! 
i build a message app in my web following this tutorial.
but As i enter the chatroom & send message, then 

"ActionController::InvalidAuthenticityToken in MessagesController#create" error occurs.
I think it means "submit" acts as html form.

but As i enter the chatroom & refresh, then log tells me that 

"Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)" 
it means actioncable is working now.

so, user has to refresh as they enter the chatroom. it is rediculous, right?
what is the reason? Why actioncable does not work when entering the chatroom at the first place?

Posted in Group Chat with ActionCable: Part 5 Discussion

Hi, chris. Thank you for taking me so far.
But i got a problem. you remember this

  $("#new_message").on "submit", (e) ->
    e.preventDefault()

but in my case, the 'e.preventDefauly()" does not work always. sometimes, it goes html like

Started POST "/chatrooms/1/messages"

And sometimes, it goes from coffees to job&channel... like

Started GET "/cable/" [WebSocket] for 127.0.0.1

Do you see any clear answer this problem? Help me:)
And why e.preventDefault() and following coffee codes do not work sometimes?
As i see log, when socket successfully connencted it works fine. But if there is no "Socket successful..." sentence, then it goes HTML way....why?!! :(