title: Rails 5 - Understanding the new action and rendering errors
body: <p>My questions is regarding section 5.10 of the official <a href="https://guides.rubyonrails.org/getting_started.html" rel="nofollow noreferrer">Rails guide</a> </p>
  
  <p>I have an <strong>articles</strong> model with fields <strong>Title</strong> and <strong>Text</strong></p>
  
  <p><strong>article.rb</strong> :</p>
  
  <pre><code>class Article &lt; ApplicationRecord
    validates :title, presence: true, length: { minimum: 5 }
  end
  </code></pre>
  
  <p><strong>articles_controller.rb</strong> :</p>
  
  <pre><code>class ArticlesController &lt; ApplicationController
  
    def index
      @articles = Article.all
    end
  
    def show
      @article = Article.find(params[:id])
    end
  
    def new
      @article = Article.new
    end
  
    def create
      @article = Article.new(article_params)
  
      if @article.save
        redirect_to @article
      else
        render 'new'
      end
    end
  
    private
  
    def article_params
      params.require(:article).permit(:title, :text)
    end
  end
  </code></pre>
  
  <p>The guide says that </p>
  
  <blockquote>
    <p>@article = Article.new</p>
  </blockquote>
  
  <p>needs to be added to the <strong>new</strong> action otherwise otherwise @article would be nil in our view, and calling <code>@article.errors.any?</code> would throw an error. Here is the <strong>new.html.erb</strong> :</p>
  
  <pre><code>&lt;%= form_with scope: :article, url: articles_path, local: true do |form| %&gt;
  
    &lt;% if @article.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;
          &lt;%= pluralize(@article.errors.count, "error") %&gt; prohibited
          this article from being saved:
        &lt;/h2&gt;
        &lt;ul&gt;
          &lt;% @article.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;p&gt;
      &lt;%= form.label :title %&gt;&lt;br&gt;
      &lt;%= form.text_field :title %&gt;
    &lt;/p&gt;
  
    &lt;p&gt;
      &lt;%= form.label :text %&gt;&lt;br&gt;
      &lt;%= form.text_area :text %&gt;
    &lt;/p&gt;
  
    &lt;p&gt;
      &lt;%= form.submit %&gt;
    &lt;/p&gt;
  
  &lt;% end %&gt;
  
  &lt;%= link_to 'Back', articles_path %&gt;
  </code></pre>
  
  <p>What I am able to understand is when there is an error, it is present in @articles so @article.errors.any? helps in showing the errors when the 'new' view is rendered. It indeed works as expected but what I am not able to understand is <code>@article = Article.new</code> in the new action should reset the @article and the errors should be lost after the user is redirected to <code>new</code>. But somehow, the errors are not lost and are indeed being displayed. How is this happening ? </p>