Jer Kehoe


410 Experience
4 Lessons Completed
0 Questions Solved


Posted in Group Chat with ActionCable: Part 4 Discussion

Had the same error, running on Rails 5.2, needed to replace form_for with form_with for the message form

<%= form_with model: [@chatroom,], :html => { :id => 'new_message'} do |f| %>

Also Rails UJS in 5.2 doesn't intercept a submit triggered by javascript, so I needed to use the method to submit the form in my keypress handler

$(document).on "turbolinks:load", ->
    $("#new_message").on "keypress", (e) ->
        if e && e.keyCode == 13
  , 'submit')