ActionView :: Template :: Error(无法打开到localhost的TCP连接:9292(连接被拒绝 - 连接(2)用于" localhost"端口9292))

时间:2016-06-28 09:35:57

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 tcp

请给我一些解决方案以解决以下错误。

这是一个聊天应用程序.... 代码和错误如下::

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'

请为此问题提供一些解决方案。

提前致谢。

1 个答案:

答案 0 :(得分:1)

看起来你正在使用private_pub gem。它需要您启动一个单独的机架服务器。

rackup private_pub.ru -s thin -E production

你做到了吗?