title: Rails Comments Ajax
body: <p>I've scoured the web All day looking for a solution to this problem. A lot of people on stack overflow have had the same issue, and I've tried all of their solutions, yet it doesn't seem to be working for me so I thought I'd give it a shot here. I'm just trying to get my page to update my comments after posting without refreshing. The problem seems to lie in my create.js.erb file, as it doesn't seem to be registering at all. Here's what I've got so far.</p>
  
  <p>The Controller:</p>
  
  <pre><code>class CommentsController &lt; ApplicationController
  
      def create
  
      @content = params[:content]
  
      @comment = Comment.create(:video_id =&gt; params[:video_id], :content =&gt; params[:content])
  
      @video = Video.find(params[:video_id])
  
      respond_to do |format| 
  
      format.html {redirect_to "/videos/#{@video.id}", flash:{success_comment: "created!"}}
  
      format.js {}
  
      end
  
    end
  
  end
  </code></pre>
  
  <p>The Create Comment Form:</p>
  
  <pre><code>  &lt;%= form_tag "/videos/#{@video.id}/comments", :method =&gt; "post", :remote =&gt; true do %&gt;
      &lt;%=label_tag :comment, nil %&gt;
  
      &lt;%=text_area_tag :content, nil, class: "commentinput" %&gt;
  
      &lt;%=submit_tag "Comment"%&gt;
  
    &lt;% end %&gt;
  </code></pre>
  
  <p>The app/views/comments/create.js.erb:</p>
  
  <pre><code>$('.comments').append('&lt;%= escape_javascript(render :partial =&gt; @comment) %&gt;');
  
  $('.commentinput').val('')
  </code></pre>
  
  <p>Could someone please tell me what I am missing here??? Thanks in advance.</p>