title: Rails 4. How to add authenticity_token to forms rendered via partial?
body: <p>On my rails app, on all pages, in the head section there are these 2 meta tags:</p>
  
  <pre><code>&lt;meta name="csrf-param" content="authenticity_token" /&gt;
  &lt;meta name="csrf-token" content="027GUZBeEkmv..." /&gt;
  </code></pre>
  
  <p>On forms not rendered using a partial there is a hidden <code>authenticity_token</code> field</p>
  
  <pre><code>&lt;input type="hidden" name="authenticity_token" value="D5TddQruJppDD3..." /&gt;
  </code></pre>
  
  <p>But this field misses if I simply load the form like this:</p>
  
  <pre><code>&lt;%= render 'shared/comment_form' %&gt;
  </code></pre>
  
  <p>Is this expected behavior ? Should I manually add an <code>authenticity_token</code> and if so how do I validate it ?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p><strong>shared/_comment_form.html.erb</strong></p>
  
  <pre><code>&lt;%= form_for([@post, @comment], :html =&gt; { :onsubmit =&gt; "validateCommentForm(event)" }, remote:true) do |f| %&gt;
      &lt;%= render 'shared/error_messages', object: f.object %&gt;
      &lt;div class="field"&gt;
          &lt;%= f.text_area :content, placeholder: "Add to the article. Make it be more" %&gt;
      &lt;/div&gt;
  
      &lt;%= f.submit "Save", class: "btn btn-info" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Also, adding <code>&lt;input type="hidden" name="authenticity_token" id="authenticity_token" value="ANYTHING" /&gt;</code> to that form still manages to post the info and create a new record...</p>