title: Message "true" flashes on main page after session timeout
body: <p>I have a Rails4 app and I'm trying to flash a custom message when a session times out due to inactivity. </p>
  
  <p>I'm doing this by configuring the <code>timeout_in</code> setting in <code>devise.rb</code>:</p>
  
  <pre><code>Devise.setup do |config|
    ...
    config.timeout_in = 30.minutes
    ...
  end
  </code></pre>
  
  <p>and adding a custom rescue to my application controller: </p>
  
  <pre><code>rescue_from CanCan::AccessDenied do |exception|
    if user_signed_in?
      flash.now.alert = exception.message
      render text: '', layout: true, status: 403
    else
      redirect_to new_user_session_path, notice: flash[:alert] || "You must login first"
    end
  end
  </code></pre>
  
  <p>Everything seems to be working fine... when the session times out, <code>flash[:alert]</code> already has the correct message so I just use that and when the user tries to access a resource without logging in first then the "You must login first" message is returned.</p>
  
  <p>This is the code in the the main.html.haml page that renders these alerts:</p>
  
  <pre><code>.container
    .main-content
      #flash
        - flash.each do |type, msg|
          %div{class: ('alert alert-dismissable fade in')}
            %button.close{data: {dismiss: :alert}} &amp;times;
            = msg
      = yield
  </code></pre>
  
  <p>The problem is that once a while I see a flash with the text "True" appearing right below the session timeout message:</p>
  
  <p><img src="https://i.stack.imgur.com/KevWw.png" alt="Message showing True"></p>
  
  <p>and I can't figure out where it's coming from. It seems that something is creating a flash message with that value. I wonder what am I doing wrong or if there a better way to display a session timeout messages. Any ideas?</p>