-1

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

Citizen
  • 11
  • 4
  • Have you tried `console.log(data)` in the `received` method of `app/assets/javascripts/channels/chatroom.coffee` to make sure you're getting data back? – hashrocket Apr 19 '20 at 15:20
  • I've tried and I'm getting data back. But I see also in my rails server this message at the end of transaction:```No template found for MessagesController#create, rendering head :no_content``` . And then if reload page I can see the message – Citizen Apr 19 '20 at 17:43
  • Do you have `remote: true` on your form? – hashrocket Apr 19 '20 at 17:56
  • Yes I have in app/views/chatroom/index.html.erb, you can see it in my github repo – Citizen Apr 19 '20 at 18:18

1 Answers1

0

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.

hashrocket
  • 2,210
  • 1
  • 16
  • 25