title: Ruby on Rails tutorial NoMethodError in Articles#index
body: <p>So I'm following the official ROR tutorial at <a href="http://guides.rubyonrails.org/getting_started.html" rel="noreferrer">http://guides.rubyonrails.org/getting_started.html</a>
  and I am stuck at section 5.8 where it teaches me how to list out all the articles</p>
  
  <p>The following are my controller and index.html.erb</p>
  
  <p>controller</p>
  
  <pre><code>class ArticlesController &lt; ApplicationController
    def new
    end
  
  
    def create
      @article = Article.new(article_params)
  
      @article.save
      redirect_to @article
    end
  
    def show
      @article = Article.find(params[:id])
    end
  
    def index
      @article = Article.all
    end
  
  
    private
    def article_params
      params.require(:article).permit(:title, :text)
    end
  
  
  end
  </code></pre>
  
  <p>index.html.erb</p>
  
  <pre><code>&lt;h1&gt;Listing articles&lt;/h1&gt;
  
  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Title&lt;/th&gt;
      &lt;th&gt;Text&lt;/th&gt;
    &lt;/tr&gt;
  
    &lt;% @articles.each do |article| %&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;%= article.title %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= article.text %&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;% end %&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I am getting the <code>NoMethodError in Articles#index</code> with the error message </p>
  
  <pre><code>undefined method `each' for nil:NilClass"
  </code></pre>
  
  <p>What's wrong? I literally copied and pasted the code from the website to see what I'm doing wrong, but still cannot fix it. </p>