the vanishing layout

I’ve stumbled upon a very weird bug which I’m – sadly – unable to reproduce.

I’m riding the edge and, after upgrading once more (after recent localized template neatness), one of my coworkers who is using Mongrel reported that the site has no layout. This bug was not reproducable with Passenger or Thin. The layout was in Haml (“application.html.haml”).

I’ve set up a blank app to use edge rails and created a scaffold with an erb layout (“application.html.erb”). The first requests indeed didn’t render a layout! Then I started to git bisect vendored rails. I started off with a fairly old revision and the template immediately showed on the next request. I continued to bisect and finished up on this commit: “a98cd7ca by Joshua Peek: Add localized templates”.

The thing that troubled me now was that even with this commit checked out, I couldn’t reproduce the bug. The layout rendered consistently. I then moved back to master and, to my surprise, the bug was gone. Not reproducable anymore. I went back to the real application in question and there it was gone, too.

So, doctor, give to me straight: am I crazy?

I’m not crazy!

Turned out that “script/server --daemon” + Mongrel + Josh Peek = no layout for you, buddy.

Bisected right down to: 858a420c by Joshua Peek: “Ensure the template format is always passed to the template finder. Now we can cleanup some nasty stuff.”

Funny that it doesn’t occur with Mongrel that isn’t daemonized.


Any possible way to create a unit test for this?

I may end up just reverting that commit.

Ticket with fix here:

I failed at creating a unit test. First of all, some tests error out if run individually and layout tests are one of them. Second, it’s really difficult to simulate a detached Mongrel simply because of the way this whole template thing bootstraps.

But I would suggest an all-around solution: no relative directory paths anywhere. Ever.