title: How can a flash message persist between requests in Rails?
body: <p>A tutorial I am following has the below code which it mentions is not quite right because the error flash persists one request longer than desired because <code>render</code> doesn't count as a request. The solution is to use <code>flash.now</code> instead. </p>
  
  <p>But how is it even possible for the error flash to persist one extra request? Given that Rails is stateless how is the information of the flash stored for the next request?</p>
  
  <pre><code>class SessionsController &lt; ApplicationController
  
    def new
    end
  
    def create
      user = User.find_by_email(params[:session][:email].downcase)
      if user &amp;&amp; user.authenticate(params[:session][:password])
        # Sign the user in and redirect to the user's show page.
      else
        flash[:error] = 'Invalid email/password combination' # Not quite right!
        render 'new'
      end
    end
  
    def destroy
    end
  end
  </code></pre>