Kevin Sylvestre
Kevin Sylvestre

Reputation: 38062

Devise Flash Message Not Begin Set on First Post

I have a Rails 3.0.9 application running Devise 1.4.2 that overrides the default devise views and displays the flash messages (if present). The problem is, the flash parameter is not being set ever on the first POST. For example: if you login without an email or password the flash will be blank. However if you login a second time (still with email and password blank) the flash is set to: "Invalid email or password". Any idea why?

Upvotes: 0

Views: 191

Answers (2)

Kostia
Kostia

Reputation: 150

I had the same problem. In my case it was authenticate_or_request_with_http_digest in ApplicationController, because it results in an additional redirect. Here's how it works:

  1. BROWSER -> APP: Post something
  2. APP -> BROWSER: Ok, but I have to redirect you to page "FOO" (setting flash)
  3. BROWSER -> APP: Give me page "FOO" without credentials
  4. APP -> BROWSER: Get Lost (now flash should have been displayed)
  5. BROWSER -> APP: Ok, give me page with credentials
  6. APP -> BROWSER: Ok (but at this time flash is already empty)

Result: No flash displayed...

Hope it helped you! Kostia

Upvotes: 1

Kevin Sylvestre
Kevin Sylvestre

Reputation: 38062

Turned out to be a conflict with another gem (Active Scaffold). Removing that gem fixes the problem.

Upvotes: 0

Related Questions