title: Rails error "undefined method `model_name' for NilClass:Class"
body: <p>I am very new to Rails and am trying to use &lt;%= render 'form' %> to include this form on posts/index</p>
  
  <pre><code>&lt;%= form_for(@post) do |post_form| %&gt;
  &lt;% if @post.errors.any? %&gt;
  &lt;div id="errorExplanation"&gt;
  &lt;h2&gt;&lt;%= pluralize(@post.errors.count, "error") %&gt; prohibited this post from being saved:&lt;/h2&gt;
  &lt;ul&gt;
  &lt;% @post.errors.full_messages.each do |msg| %&gt;
    &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
    &lt;% end %&gt;
    &lt;/ul&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
  
  &lt;%= post_form.label :name %&gt;: &lt;%= post_form.text_field :name %&gt;
  &lt;br/&gt;
  &lt;%= post_form.label :subject %&gt;: &lt;%= post_form.text_field :subject %&gt;
   &lt;br/&gt;
  &lt;%= post_form.label :email %&gt;: &lt;%= post_form.text_field :email %&gt;
   &lt;br/&gt;
  &lt;%= post_form.label :content %&gt;: &lt;%= post_form.text_area :content %&gt;
  
  &lt;%= post_form.submit %&gt;
  </code></pre>
  
   
  
  <p>the error caused says undefined method `model_name' for NilClass:Class</p>