mardi 28 juin 2016

ActionView::Template::Error (Failed to open TCP connection to localhost:9292 (Connection refused - connect(2) for "localhost" port 9292))

Please give me some solution for the following error.

This is a chat application.... and the code and error is as follows::

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 %>

Error shown on Console:

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'

Please give some solution for this issue.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire