From 083ec3e747c44ac0989f9dccd3db9e1385248c8f Mon Sep 17 00:00:00 2001 From: Beatrice Olivera Date: Tue, 4 Sep 2018 11:49:18 +0100 Subject: [PATCH] added message sending --- app/javascript/packs/chatrooms.js | 15 ++++++++------- app/views/chat_rooms/show.html.erb | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/javascript/packs/chatrooms.js b/app/javascript/packs/chatrooms.js index a72d582..a29046f 100644 --- a/app/javascript/packs/chatrooms.js +++ b/app/javascript/packs/chatrooms.js @@ -19,17 +19,18 @@ App['chatroom' + chatroomId] = App.cable.subscriptions.create({ connected: () => { }, received: data => { + console.log(data) } }) // Testing ActionCable -// const testBtn = document.getElementById('test-btn') -// testBtn.addEventListener('click', event => { -// fetch(`/chat_rooms/${chatroomId}/cable_testing` , { -// method: 'POST', -// body: JSON.stringify({}) -// }) -// }) +const testBtn = document.getElementById('test-btn') +testBtn.addEventListener('click', event => { + fetch(`/chat_rooms/${chatroomId}/cable_testing` , { + method: 'POST', + body: JSON.stringify({}) + }) +}) diff --git a/app/views/chat_rooms/show.html.erb b/app/views/chat_rooms/show.html.erb index fd9e62f..57f416c 100644 --- a/app/views/chat_rooms/show.html.erb +++ b/app/views/chat_rooms/show.html.erb @@ -1,3 +1,4 @@ +