2016-06-28 39 views
1

請給我一些解決方案,以解決以下錯誤。ActionView :: Template :: Error(打開到本地主機的TCP連接失敗:9292(Connection refused - connect(2)for「localhost」port 9292))

這是一個聊天應用.... 和代碼和誤差如下::

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

它看起來像你正在使用private_pub寶石。它需要您啓動一個單獨的機架服務器。

rackup private_pub.ru -s thin -E production 

你這樣做了嗎?

+0

感謝您的幫助。 @Uzbekjon。我們(新手或初級開發者)需要像你這樣的人幫忙。再次感謝。 –

相關問題