【发布时间】:2020-04-19 12:21:13
【问题描述】:
我正在做关于 message_me 应用程序的教程,但我编写并点击 enterwan 的消息不会显示在索引聊天室页面上,除非我重新加载页面。我已经尝试使用两个浏览器 Firefox 和 Chromium,两个控制台都在同一文件和同一行中向我显示错误:app/assets/javascripts/channels/chatroom.coffee:
}, $('#message-container').append(data.mod_message), scroll_bottom());
ReferenceError: 数据未定义
【问题讨论】:
-
您是否在
app/assets/javascripts/channels/chatroom.coffee的received方法中尝试过console.log(data)以确保您正在取回数据? -
我已经尝试过,我正在取回数据。但我也在我的 Rails 服务器中看到了事务结束时的这条消息:
No template found for MessagesController#create, rendering head :no_content。然后如果重新加载页面我可以看到消息 -
你的表单上有
remote: true吗? -
是的,我在 app/views/chatroom/index.html.erb 中有,你可以在我的 github repo 中看到它
标签: ruby-on-rails-5 actioncable