title: Ruby on rails AJAX submit form error
body: <p>So I'm trying to update my comments section with AJAX without the full page refresh for a college project. However I can't seem to get this working.
  In the console it gives me s</p>
  
  <blockquote>
    <p>Failed to load resource: the server responded with a status of 500 (Internal Server Error)</p>
  </blockquote>
  
  <p>My show.html.erb file:</p>
  
  <pre><code>&lt;h1&gt;Title: &lt;%= @post.title %&gt;&lt;/h1&gt;
  &lt;h2&gt;Body: &lt;%= @post.body %&gt;&lt;/h2&gt;
  &lt;hr /&gt;
  &lt;h1&gt;Your comments&lt;/h1&gt;
  &lt;%= link_to "View comments", "#", id: "comments-link" %&gt;
  &lt;ol id="comments"&gt;
      &lt;%= render 'comments' %&gt;
  &lt;hr /&gt;
  &lt;h1&gt;Create comment&lt;/h1&gt;
  
      &lt;%= form_for(@comment, :html =&gt; {class: "form", role: "forms"}, :url =&gt; post_comments_path(@post), remote: true)  do |comm| %&gt;
  &lt;div class="container"&gt;
      &lt;div class="input-group input-group-md"&gt;
              &lt;%= comm.label :body %&gt;
              &lt;%= comm.text_area :body, class: "form-control", placeholder: "Enter a comment" %&gt;
      &lt;/div&gt;
                  &lt;%= comm.submit "custom", id: "button" %&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  &lt;/ol&gt;
  </code></pre>
  
  <p>My comments.coffee:</p>
  
  <pre><code>$(document).on "page:change", -&gt;
    $('#comments-link').click -&gt;
      $('#comments').fadeToggle()
      $('#comments_body').focus()
  </code></pre>
  
  <p>My create.js.erb:</p>
  
  <pre><code>$('#comments').append("&lt;%= j render @comment  %&gt;");
  </code></pre>
  
  <p>and my Comments controller:</p>
  
  <pre><code>class CommentsController &lt; ApplicationController
  
  def index
  
  end
  
  def new
  end
  
  def new
      @comment = Comment.new
  end
  
  def create
      @comment = Comment.new(comment_params)
      @comment.post_id = params[:post_id]
      if @comment.save
          flash[:success] = "Successfully created comment"
          respond_to do |format|
              format.html { redirect_to post_path(@comment.post_id) }
              format.js
          end
      else
          flash[:danger] = "Failed to create comment"
          redirect_to root_path
      end
  end
  
  private
  
  def comment_params
      params.require(:comment).permit(:body)
  end
  end
  </code></pre>
  
  <p>I may have missed some files so just let me know, it is basic as it's just a post and comment system - no styling needed for the project, so yeah. I have been trying this for the last 4 hours and other places just don't work. I've looked on here, Youtube - everywhere however no one else's code works for me so I have come here! Thank's for you're help.</p>
  
  <p>EDIT:</p>
  
  <p>I noticed it said to create a view in the error response, however I made that view and rendered the comment's body onto the create.html.erb however I just need to display the form now.</p>