title: Rails JS respond to create action fail
body: <p>I'm having trouble getting the current page to reload, after posting a remote form in Rails 4, to create join object in my db. It works fine for another model association in my app, but not here....</p>
  
  <p>View Form:</p>
  
  <h1>select from dropdown which collection to assign to:</h1>
  
  <pre><code>&lt;% unless current_user == nil %&gt;
  &lt;div class="btn-group pull-right"&gt;
    &lt;a class="btn dropdown-toggle" data-toggle="dropdown" href="#"&gt;
      Collect
  &lt;span class="caret"&gt;&lt;/span&gt;
    &lt;/a&gt;
    &lt;ul class="dropdown-menu"&gt;
       &lt;% current_user.collections.each do |collection| %&gt;
      &lt;% unless  CollectionPiece.where(:collection_id =&gt; collection.id, :piece_id =&gt; @piece.id).exists? %&gt;
      &lt;li&gt;&lt;%= link_to raw("&lt;i class='glyphicon glyphicon-plus'&gt;&lt;/i&gt;  #{collection.title}"), collection_pieces_path(:collection_piece =&gt; {:piece_id =&gt; @piece.id, :collection_id =&gt; collection.id}), :remote =&gt; true, class: "", :method =&gt; :post %&gt;&lt;/li&gt;
      &lt;% end %&gt;
       &lt;% end %&gt;
          &lt;li&gt;&lt;%= link_to raw("&lt;i class='glyphicon glyphicon-th-large'&gt;&lt;/i&gt;  New Collection"), new_collection_path, :class =&gt; "" %&gt;&lt;/li&gt;
     &lt;/ul&gt;
   &lt;/div&gt;
   &lt;% end %&gt;
  </code></pre>
  
  <p>Collection Piece controller:</p>
  
  <pre><code>class CollectionPiecesController &lt; ApplicationController
  
  
  after_action :collection_email, only: :create
  
  
  def create
      @collection_piece = CollectionPiece.create(collection_piece_params)
  
      respond_to do |format|
        if @collection_piece.save
          format.html { redirect_to :back, notice: 'Collection was successfully created.' }
        else
          format.html { redirect_to :back, notice: 'Collection was not successfully created.' }
        end
      end
  end
  
  def destroy
      @collection_piece = CollectionPiece.where(collection_piece_params)
      respond_to do |format|
        if @collection_piece.first.destroy
          format.js { redirect_to :back, notice: 'Collection was successfully destroyed.' }
        else
          format.js { redirect_to :back, notice: 'Collection was not successfully destroyed.' }
        end
      end
  end
  
  def collection_email
      @profile = current_user.profile
      @piece = Piece.find(params[:collection_piece][:piece_id])
      @collection = Collection.find(collection_piece_params[:collection_id])
      UserMailer.collection_email(@profile.user, @piece, @collection).deliver
       end
  
     private
  
  # Never trust parameters from the scary internet, only allow the white list through.
  def collection_piece_params
    params.require(:collection_piece).permit(:piece_id, :collection_id)
  end
  
  
  
  end
  </code></pre>
  
  <p>create.js.erb:</p>
  
  <pre><code>console.log("why you no work?");
  location.reload();
  </code></pre>
  
  <p>Hope you can help, let me know if you need more info?</p>