Background:
I’ve been trying for months to upgrade devise to the latest version, but the major stumbling block seems to be a change introduced in 1.2.0, so I’m focusing on upgrading to 1.2.0 right now. All the devise flash messages are correctly showing up in 1.1.7 and none of the devise flash message are showing up in 1.2.1. The ONLY change between the messages working to not working is the devise upgrade. For the purpose of this question, I’ll focus on the sessions controller flash messages, but all other devise flash messages stopped working.
In 1.1.7:
In the sessions#new form, I type in a correct email and an INVALID email. I click submit. I get the flash[:alert]: “Invalid email or password.”
In 1.2.1:
In the sessions#new form, I type in a correct email and an INVALID email. I click submit. I get no alert.
SessionsController:
class User::SessionsController < Devise::SessionsController
layout "no_chrome", :only => :new
skip_authorization_check
before_filter :sign_out_all_scopes, :only => %w[new create]
protect_from_forgery :except => [:new, :create]
skip_before_filter :verify_authenticity_token
def create
super
end
end
The view: sessions/new.html.erb
<div class="form_container">
<%= flash_div(:alert) %>
<%= simple_form_for @user, :url => user_session_path do |form| %>
<%= form.input :email %>
<%= form.input :password, :required => true %>
<%= form.submit "Sign in", :class=>"purple submit_button" %>
<% end %>
</div>
In application_helper.rb
def flash_div(kind)
unless flash[kind].blank?
text = "<p>#{flash[kind]}</p>"
content_tag :div, text.html_safe, :id => "flash", :class => kind
end
end
Any help would be greatly appreciated as I’ve been trying to do this upgrade on and off for months. I also want to point out that everything besides the flash messages is working after the upgrade.
SOLUTION:
Remove before_filter :sign_out_all_scopes
Remove before_filter :sign_out_all_scopes