Rails Troubleshooting Again

In the course of developing a couple themes for the Typo Theme Contest, I ran into some troubles with Typo. Running it locally with Webrick, I kept getting random errors. First, the stylesheet wouldn't load, or it'd stop loading midway through; then I'd reload the page, and I'd get a random, meaningless error; I'd reload once more and everything would work.

But then it stopped working. I got an error which I didn't understand, exactly, but which pointed to a problem in the session. Index string something or other.

Generally speaking, if you're getting wonky behavior from Rails, blowing away the sessions is a good place to start (assuming that simply restarting Webrick doesn't do the trick—and it didn't). Ruby on Rails stores its sessions in the file system, so I went to my command-line, typed cd /tmp and looked for the ruby_sess files. They weren't there. I was mystified.

Then, thankfully, somebody on #rubyonrails reminded me that you can set your sessions to store in the database. If you open environment.rb for Typo, and do a find for "sess," you'll see that Typo is one of the apps that does this (and you can see how to do it yourself).

The solution? Log in to the mysql server, select the Typo database, and remove from sessions.

posted in: rails, tips and tricks    |     51 comments