title: Private_pub gem and Rails 4.1.1. The page doesn't get updated after sending a message
body: <p>For some reason, the page doesn't get updated after sending a message. It works only after refreshing the page manually. I have partially followed this tutorial <a href="http://railscasts.com/episodes/316-private-pub" rel="nofollow">http://railscasts.com/episodes/316-private-pub</a> but something is not right. Here are my files:</p>
  
  <p>app/controllers/main_controller.rb  </p>
  
  <pre><code>class MainController &lt; ApplicationController
    def application
      @messages = Message.all
    end
  end
  </code></pre>
  
  <p>app/controllers/messages_controller.rb</p>
  
  <pre><code>class MessagesController &lt; ApplicationController
      def create
          @message = Message.create(message_params)
      end
  
      private
  
          def message_params
              params.require(:message).permit(:content)
          end
  end
  </code></pre>
  
  <p>app/views/layouts/application.html.erb</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"&gt;
      &lt;%= viewport_meta_tag %&gt;
      &lt;title&gt;&lt;%= content_for?(:title) ? yield(:title) : "Theater" %&gt;&lt;/title&gt;
      &lt;%= csrf_meta_tags %&gt;
  
      &lt;!-- Le HTML5 shim, for IE6-8 support of HTML elements --&gt;
      &lt;!--[if lt IE 9]&gt;
        &lt;script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"&gt;&lt;/script&gt;
        &lt;script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.3.0/respond.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;![endif]--&gt;
  
      &lt;%= stylesheet_link_tag "application", :media =&gt; "all" %&gt;
  
      &lt;!-- For third-generation iPad with high-resolution Retina display: --&gt;
      &lt;!-- Size should be 144 x 144 pixels --&gt;
      &lt;%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel =&gt; 'apple-touch-icon-precomposed', :type =&gt; 'image/png', :sizes =&gt; '144x144' %&gt;
  
      &lt;!-- For iPhone with high-resolution Retina display: --&gt;
      &lt;!-- Size should be 114 x 114 pixels --&gt;
      &lt;%= favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel =&gt; 'apple-touch-icon-precomposed', :type =&gt; 'image/png', :sizes =&gt; '114x114' %&gt;
  
      &lt;!-- For first- and second-generation iPad: --&gt;
      &lt;!-- Size should be 72 x 72 pixels --&gt;
      &lt;%= favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel =&gt; 'apple-touch-icon-precomposed', :type =&gt; 'image/png', :sizes =&gt; '72x72' %&gt;
  
      &lt;!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: --&gt;
      &lt;!-- Size should be 57 x 57 pixels --&gt;
      &lt;%= favicon_link_tag 'apple-touch-icon-precomposed.png', :rel =&gt; 'apple-touch-icon-precomposed', :type =&gt; 'image/png' %&gt;
  
      &lt;!-- For all other devices --&gt;
      &lt;!-- Size should be 32 x 32 pixels --&gt;
      &lt;%= favicon_link_tag 'favicon.ico', :rel =&gt; 'shortcut icon' %&gt;
      &lt;%= javascript_include_tag "application" %&gt;
    &lt;/head&gt;
    &lt;body data-no-turbolink="true"&gt;
      &lt;div id="wrap"&gt;
  
        &lt;%= bootstrap_flash %&gt;
        &lt;%= yield %&gt;
  
        &lt;div id="push"&gt;&lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div id="footer"&gt;
        &lt;div class="container" align="center"&gt;
          &lt;p id="footer-content"&gt;Footer&lt;/p&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>app/views/main/application.html.erb</p>
  
  <pre><code>&lt;div class="container-fluid"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-4"&gt;Chat column
              &lt;ul id="chat"&gt;
                  &lt;%= render @messages %&gt;
              &lt;/ul&gt;
  
              &lt;%= form_for Message.new, remote: true do |f| %&gt;
                  &lt;%= f.text_field :content %&gt;
                  &lt;%= f.submit "Send" %&gt;
              &lt;% end %&gt;
              &lt;%= subscribe_to "messages/new" %&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>app/views/messages/create.js.erb</p>
  
  <pre><code>&lt;% publish_to "messages/new" do %&gt;
      $("#chat").append("&lt;%= j render(@message) %&gt;");
      $("#chat").animate({
          scrollTop: $("#chat").height()},
          "fast");
  &lt;% end %&gt;
  $("#new_message")[0].reset();
  </code></pre>
  
  <p>app/views/messages/_message.html.erb</p>
  
  <pre><code>&lt;li&gt;
      &lt;span class="created_at"&gt;&lt;%= message.created_at.strftime("%H:%M") %&gt;&lt;/span&gt;
      &lt;%= message.content %&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>config/routes.ru</p>
  
  <pre><code>Rails.application.routes.draw do
  
      resources :messages
  
      get 'main/application'
      root 'welcome#index'
  end
  </code></pre>
  
  <p>app/models/message.rb</p>
  
  <pre><code>class Message &lt; ActiveRecord::Base
  end
  </code></pre>
  
  <p>Gemfile</p>
  
  <pre><code>source 'https://rubygems.org'
  
  gem 'thin'
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '4.1.1'
  # Use postgresql as the database for Active Record
  gem 'pg'
  # Use SCSS for stylesheets
  gem 'sass-rails', '~&gt; 4.0.3'
  # Use Uglifier as compressor for JavaScript assets
  gem 'uglifier', '&gt;= 1.3.0'
  # Use CoffeeScript for .js.coffee assets and views
  gem 'coffee-rails', '~&gt; 4.0.0'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer',  platforms: :ruby
  
  # Use jquery as the JavaScript library
  gem 'jquery-rails'
  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
  gem 'turbolinks'
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
  gem 'jbuilder', '~&gt; 2.0'
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', '~&gt; 0.4.0',          group: :doc
  
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring',        group: :development
  
  gem 'private_pub'
  gem 'rails_12factor', group: :production
  
  gem 'bootstrap-sass', '~&gt; 3.2.0'
  gem 'autoprefixer-rails'
  gem 'bootstrap-sass-extras'
  </code></pre>
  
  <p>app/assets/javascripts/application.js</p>
  
  <pre><code>//= require jquery
  //= require bootstrap-sprockets
  //= require private_pub
  //= require jquery_ujs
  //= require turbolinks
  //= require_tree .
  </code></pre>
  
  <p>I have also ran</p>
  
  <pre><code>rails g private_pub:install
  rackup private_pub.ru -s thin -E production
  </code></pre>
  
  <p>as private_pub requires it.</p>
  
  <p>Here is a piece of server log that represents the POST after clicking the 'Send' button:</p>
  
  <pre><code>Started POST "/messages" for 127.0.0.1 at 2014-08-01 19:36:44 +0300
  Processing by MessagesController#create as JS
    Parameters: {"utf8"=&gt;"✓", "message"=&gt;{"content"=&gt;"Testing"}, "commit"=&gt;"Send"}
     (0.4ms)  BEGIN
    SQL (1.1ms)  INSERT INTO "messages" ("content", "created_at", "updated_at") VALUES ($1, $2, $3) RETURNING "id"  [["content", "Testing"], ["created_at", "2014-08-01 16:36:44.301042"], ["updated_at", "2014-08-01 16:36:44.301042"]]
     (1.0ms)  COMMIT
    Rendered messages/_message.html.erb (0.6ms)
    Rendered messages/create.js.erb (7.6ms)
  Completed 200 OK in 21ms (Views: 11.7ms | ActiveRecord: 2.9ms)
  </code></pre>
  
  <p>I hope I have provided information enough. If not, please request more. Thank you in advance.</p>