Search code examples
ruby-on-rails-5actioncable

Rails 5 message app wan't show chatroom messages unless reloaded


I'm doing tutorial on message_me app but messages I write and hit enterwan't show up on index chatroom page unless I reload the page. I've tried with two browsers Firefox and Chromium and both consoles show me the error in same file and same line: app/assets/javascripts/channels/chatroom.coffee: }, $('#message-container').append(data.mod_message), scroll_bottom());

ReferenceError: data is not define

And here is my app: https://github.com/Citizen1/message_me


Solution

  • The issue is in your chatroom.coffee file. You have to indent the lines under received: (data):

    received: (data) ->
      $('#message-container').append data.mod_message
      scroll_bottom()
    

    CoffeeScript has strict indenting guidelines.