title: rails undefined method `each' for nil:NilClass
body: <p>I'm following the tutorial found <a href="http://guides.rubyonrails.org/getting_started.html">here</a>. It's simple, and I've followed the instructions exactly to step 6.7. At this point, I get the error </p>
  
  <pre><code>undefined method `each' for nil:NilClass 
  </code></pre>
  
  <p>when I try to access index.html.erb on the rails server.</p>
  
  <p>I know the database is working fine, because I can do everything mentioned in step 6.3, create new posts and show/edit/destroy them with absolutely no problems.</p>
  
  <p>Specifically, the issue is with the line </p>
  
  <pre><code>&lt;% @posts.each do |post| %&gt;
  </code></pre>
  
  <p>and it's essentially claiming that <code>@posts</code> is nil.</p>
  
  <p>I appreciate any help for this ROR newbie! Thanks.</p>
  
  <p><strong>index.html.erb</strong></p>
  
  <pre><code>&lt;h1&gt;Hello, Rails!&lt;/h1&gt;
  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Title&lt;/th&gt;
      &lt;th&gt;Content&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
  
  &lt;% @posts.each do |post| %&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;%= post.name %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= post.title %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= post.content %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Show', post %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Edit', edit_post_path(post) %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Destroy', post, :confirm =&gt; 'Are you sure?',
                                       :method =&gt; :delete %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;/table&gt;
  
  &lt;br /&gt;
  
  &lt;%= link_to "My Blog", posts_path %&gt;
  </code></pre>
  
  <p><strong>posts_controller.rb</strong></p>
  
  <pre><code>class PostsController &lt; ApplicationController
    # GET /posts
    # GET /posts.json
    def index
      @posts = Post.all
  
      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @posts }
      end
    end
  </code></pre>