请给我一些解决方案以解决以下错误。
这是一个聊天应用程序.... 代码和错误如下::
conversations_controller.rb
def create
if Conversation.between(params[:sender_id],params[:recipient_id]).present?
@conversation = Conversation.between(params[:sender_id],params[:recipient_id]).first
else
@conversation = Conversation.create!(conversation_params)
end
render json: { conversation_id: @conversation.id }
end
Create.js.erb
<% publish_to @path do %>
alert(@path);
var id = "<%= @conversation.id %>";
var chatbox = $("#chatbox_" + id + " .chatboxcontent");
var sender_id = "<%= @message.user.id %>";
var reciever_id = $('meta[name=user-id]').attr("content");
chatbox.append("<%= j render( partial: @message ) %>");
chatbox.scrollTop(chatbox[0].scrollHeight);
if (sender_id != reciever_id) {
chatBox.chatWith(id);
chatbox.children().last().removeClass("self").addClass("other");
chatbox.scrollTop(chatbox[0].scrollHeight);
chatBox.notify();
}
<% end %>
控制台上显示错误:
ActionView::Template::Error (Failed to open TCP connection to localhost:9292 (Connection refused - connect(2) for "localhost" port 9292)):
1: <% publish_to @path do %>
2: alert(@path);
3: var id = "<%= @conversation.id %>";
4: var chatbox = $("#chatbox_" + id + " .chatboxcontent");
app/views/messages/create.js.erb:1:in `_app_views_messages_create_js_erb___1855030059461646481_70563200'
请为此问题提供一些解决方案。
提前致谢。
答案 0 :(得分:1)