» tagged pages
» logout
User:jerryk
Return to Ruby, Rails and Related

My Rails flash text is stuck!??!?!

Make further edits, (or Cancel)

(or Cancel)

(Editing anonymously: to be credited for your changes, login or register a new account)

(or Cancel)

Tags Applied to this Entry

1 person has tagged this page:

The following is a brief description of a problem I recently encountered while working on a Rails project. I haven’t had time to fully research what happened, so some of what appears here may be tantamount to a yeti sighting. Any Rails cluelessness, general ineptitude, or incalculable ignorance demonstrated below are solely my fault. It’s my hope that if someone googles around trying to solve a similar problem, they may stumble across this and find it modestly useful.

The problem was as follows. I had a Rails app that had been working correctly for several weeks. During deployment I had to switch from filesystem backed session storage to database session storage to deal with the fact that the application was being served by multiple web servers lying behind a load balancer. I altered my environments.rb in the usual recommended manner, created a sessions table in MySQL, and was off to the races. Or so I thought…

The app proceeded to basically work… except the flash text I was using to communicate status text never went away. There it was… haunting me from page to page… “Login successful!” Thank you, but I got it the first time. Begone, dam-ned unsightly green box that looked fine the first time, but that doesn’t still need to besmirch my otherwise pristine browser window!

Switching back to filesystem sessions made the problem go away, and the flash returned to behaving as usual. Going back to the database restored the problem.

My configuration was Rails 1.0.0, Ruby 1.8.4, and the 2.7 mysql gem. I was running a 4.1.x series MySQL, and I tried this on both a Mac OS X system, and two Red Hat Enterprise Linux servers with the same results.

After I groveled in puzzlement in the rubyonrails IRC channel for a while, Jeremy Durham and Marcel Molina both suggested switching to edge rails with ‘rake freeze_edge’. Given that time was running short, the problem appeared persistent, and I’m a newcomer to the source code of Rails itself and not yet entirely confident at my ability to troubleshoot apparent oddities in it (or even yeti sightings), I did this…

... and the problem utterly went away. This leads me to suspect (although remember, I may have seen the yeti here somewhere) that something was a bit amiss in or around the 1.0.0 Rails gem involving database backed sessions, and that this problem has been remedied since then in the Rails subversion tree. Everything else appears to not have suffered in any way from switching to the trunk version of rails.

In summary, as much for any search engines indexing this page as for any human readers my problem was:

  • Rails flash text got “stuck” on my display, as if the underlying session data wasn’t getting rid of it automatically as it’s supposed to, and the problem only occurred when I was using database-stored sessions (with MySQL, on both OS X and RedHat Enterprise Linux)
  • Switching back to filesystem-stored sessions restored the normal behavior; it could be re-induced at any point by going back to db-sessions.
  • Switching to edge rails with ‘rake freeze_edge’ seems to solve the problem.
Username:
Password:
(or Cancel)