title: rails .js.erb views does not work on production server since it work on development machine
body: <p>I don't have any idea why code works on development machine, but doesn't work on production server. I am trying to create live chat between operator and user. In development machine the user's interface and operator's works fluently. I am using pusher as web-sockets. Actually every js.erb view does not work at all in production server. There is some parts of my view.</p>
  
  <p>_show.html.erb:</p>
  
  <pre><code>&lt;%= content_tag :div, id: "chat-heading", class: %w(mpreview migedit r).include?(action_name) ? 'panel-heading2' : 'panel-heading', style: "font-size:14px;" do %&gt;
    &lt;%= t :chat_heading %&gt;
    &lt;i class="fa fa-arrow-up" aria-hidden="true" style="float: right;"&gt;&lt;/i&gt;
  &lt;% end %&gt;
  &lt;div class="panel panel-primary" style="display: none" id="chat-primary" tabindex="0"&gt;
      &lt;%= content_tag :div, class: 'panel-body', id: 'messages', data: {url: "/#{params[:locale]}/chats/#{@chat.id}/messages/"} do %&gt;
        &lt;% unless @messages.total_pages &lt; 2 %&gt;
          &lt;div class="row" id="show-more-aligment"&gt;
            &lt;div class="col-md-4 col-md-offset-5" style="margin-bottom: 20px;"&gt; 
              &lt;%= link_to 'Show more', url_for(:controller =&gt; 'home', :action =&gt; 'index', :page =&gt; 2, :locale =&gt; params[:locale]), :remote =&gt; true, :id =&gt; 'show_more_link' %&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;% end %&gt;
      &lt;ul class="chat" id="chat-ul"&gt;
        &lt;%  @messages.reverse_each do |message| %&gt;
          &lt;%= render partial: 'messages/message', locals: {message: message} %&gt;
        &lt;% end %&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
      &lt;div class="panel panel-footer"&gt;
      &lt;div class="row"&gt;
        &lt;%= simple_form_for @chat.messages.build, url: "/#{params[:locale]}/chats/#{@chat.id}/messages/", :user_id =&gt; current_user, remote: true, :html =&gt; {:autocomplete =&gt; "off"} do |f| %&gt;
            &lt;div class="col-md-10"&gt; 
            &lt;%= f.input :text, required: true, as: :string, :class =&gt; 'btn-input form-control input-sm', :placeholder =&gt; "Type your message here...", :label =&gt; false %&gt;
            &lt;/div&gt;
            &lt;div class="col-md-2"&gt;
            &lt;%= f.submit 'Send', :class =&gt; 'btn-chat btn btn-warning btn-sm form-control msg-submit' %&gt;
            &lt;/div&gt;
          &lt;% end %&gt;
        &lt;% end %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>render of _show.html.erb:</p>
  
  <pre><code>&lt;% if user_signed_in?  %&gt;
    &lt;%= content_tag :div, class: %w(mpreview migedit r).include?(action_name) ? 'welcome_chat2' : 'welcome_chat' do %&gt;
      &lt;%= render 'chats/show' %&gt;
    &lt;% end %&gt; 
  &lt;% end %&gt;
  </code></pre>
  
  <p>controller for create method:</p>
  
  <pre><code>def create
      @message = @chat.messages.new(params[:message])
      @message.user = current_user
      respond_to do |format|
        if @message.save
          format.html {redirect_to @chat}
          format.js { Pusher.trigger("live_chat_#{@chat.id}", 'chat', {message: @message}) }
        else
          format.html {render 'new'}
          format.js
        end
      end
    end
  </code></pre>
  
  <p>create.js.erb:</p>
  
  <pre><code>$('#message_text').val('');
  </code></pre>
  
  <p>index.js.erb(adding new sent message to chat div):</p>
  
  <pre><code>if ($('#chat-ul li').length == 0){
    $('ul.chat').html("&lt;%= escape_javascript(render partial: 'messages/message', locals: {message: @message}) %&gt;");
  }
  else {
    $('ul.chat li:last').after("&lt;%= escape_javascript(render partial: 'messages/message', locals: {message: @message}) %&gt;");
  }
  </code></pre>
  
  <p>That's it if I didn't miss something. Basically this code should add new message to database and render it on form send. Actually it saves to database but do not append it to the messages div. It gives 500 internal error. And what is most important in development machine the same exact code works like a charm, but in production it does not. This must be something with server or environment config I guess. Maybe someone has some ideas? Thanks in an advance.</p>
  
  <p><a href="http://i.stack.imgur.com/LHm8r.png" rel="nofollow">ERROR IS HERE</a></p>