Chat Using Action Cable part 3 - Chatroom and ChatroomUsers Association
I've been playing around and trying to implement a chat such as slack as shown on Chris's screencast. On Chatroom index I'm able to Show, Edit, Join, and Leave. However, when I clicked on Show even though it redirects me to the right chatroom I'm not able to send messages in real time because I haven't clicked on "joined" prior to entering the chatroom as a member. Is there a way to join the room while I'm already on the chatroom.
*** <td><%= link_to "Join", chatroom_chatroom_users_path(@chatroom), method: :post %></td>*** <p> <strong>Welcome to my chatroom:</strong> <%= @chatroom.name %> </p> <div data-behavior='messages' data-chatroom-id='<%= @chatroom.id %>'> <% @messages.each do |message| %> <%= render message %> <% end %> </div> <%= form_for [@chatroom, Message.new] do |f| %> <%= f.text_area :body, rows: 1, class: "form-control", autofocus: true %> <% end %>
I've added ***<%= link_to "Join", chatroom_chatroom_users_path(@chatroom), method: :post %>*** on chatroom's show page to join. pic: ![http://prntscr.com/hj0egi] !
but it crashes giving me this error:![http://prntscr.com/hj0dfs]