title: undefined method `model_name' for NilClass:Class -NULL value?
body: <p>My Rails app is generating this error whenever validation aren't met:</p>
  
  <pre><code>undefined method `model_name' for NilClass:Class
  </code></pre>
  
  <p><strong>post_controller.rb</strong>:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
    def index
      @posts = Post.all
    end
  
    def show
      @show_post = Post.find(params[:id])
    end
  
    def new
      @new_post = Post.new
    end
  
  
  
    def create
       @create_post = Post.new(params[:post])
  
       if @create_post.save
         redirect_to posts_path, :notice =&gt; "Your post was save"
         else
       render "new"
       end
    end
  
  
  
  
    def edit
      @edit_post = Post.find(params[:id])
    end
  
  
    def update
      @update_post = Post.find(params[:id])
      if @update_post.update_attributes(params[:post])
        redirect_to posts_path , :notice =&gt; "YOUR POST has been update"
      else
         render "edit"
  
      end
  
    end
  
    def destroy
      @destroy_post = Post.find(params[:id])
      @destroy_post.destroy
      redirect_to posts_path, :notice =&gt; "You succressfuly delete #{@destroy_post}"
  
    end
  end
  </code></pre>
  
  <p><strong>index.html.erb</strong>:</p>
  
  <pre><code>&lt;h1&gt;My blog&lt;/h1&gt;
  
  &lt;% @posts.each do |post|%&gt;
      &lt;h2&gt;&lt;%= link_to post.title, post%&gt;&lt;/h2&gt;
      &lt;p&gt;&lt;%= post.content%&gt;&lt;/p&gt;
      &lt;p&gt;
          &lt;%= link_to "EDIT", edit_post_path(post)%&gt;
          &lt;%= link_to "Delete", post ,:confirm =&gt; "Are you sure?" , :method =&gt; :delete%&gt;
      &lt;/p&gt;
      &lt;hr&gt;
  &lt;% end%&gt;
  
  &lt;p&gt;
      &lt;%= link_to "Add new post", new_post_path %&gt;
  
  
  &lt;/p&gt;
  </code></pre>
  
  <p><strong>post.rb</strong>:</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
     attr_accessible :title, :content
  
     validates :title, :content, :presence =&gt; true
     validates :title, :length =&gt; { :minimum =&gt; 2}
     validates :title, :uniqueness =&gt;true
  
  end
  </code></pre>
  
  <p>The error is raised in the following context:</p>
  
  <pre><code>Extracted source (around line #2):
  
  1: &lt;h1&gt;Add new post&lt;/h1&gt;
  2: &lt;%= form_for @new_post do |form|%&gt;
  3:  &lt;p&gt;
  4:      &lt;%= form.label :title%&gt;&lt;br /&gt;
  5:      &lt;%= form.text_field :title%&gt;
  </code></pre>
  
  <p>I don't think I have a problem with my code? Or the value is just <code>nil</code> and that's why it comes with this error?</p>