我是Ruby on Rails的新手,我正在尝试遵循本教程(https://scotch.io/tutorials/asynchronous-chat-with-rails-and-actioncable?fbclid=IwAR19UbyiXHkG8OvSrZ1jXJr5gFK8lnjkqEFdMxaYYMyFisKmwlAXQbyx_GU)。我的Clearance gem设置很好,并且可以正确显示提交消息的表单,但是如果我尝试提交消息,则会收到404错误。
来自检查元素的完整错误: rails-ujs.self-2b8935521e2301b06b45bd42e623eb0c0acf76c3a6ba383b7429c6a2884f8c23.js?body = 1:217 POST http://localhost:3000/ 404(未找到)Rails.ajax @ rails-ujs.self-2b8935521e2301b06b45bd42e623eb0c0acf76c3a6ba383b7429c6a2884f8c23.js?body = 1:217 Rails.handleRemote @ rails-ujs.self-2b8935521e2301b06b45bd42e623eb0c0acf76c3a6ba383b7429c6a2884f8c23.js?body = 1:573 (匿名)@ rails-ujs.self-2b8935521e2301b06b45bd42e623eb0c0acf76c3a6ba383b7429c6a2884f8c23.js?body = 1:174
views / chats / index.html.erb
<h1>Demo Chat</h1>
<div id="messages">
<%= render @messages %>
</div>
<%= form_with url: '#', html: {id: 'new-message'} do |f| %>
<%= f.label :body %>
<%= f.text_area :body, id: 'message-body' %>
<br>
<%= f.submit %>
<% end %>