You know those times when you’re looking all over the house for something and then somebody says, “Is that it in your other hand?”
Last night I spent at least an hour trying to figure out why I was getting a
nil.rewrite error from Rails’s
url_for method. I’ve seen hard-to-debug errors from there before, so I dug right down into it, but I couldn’t figure out why the
@url variable was set in some cases and not in others… and then I determined that it actually was being set in all cases, but then it was mysteriously blank by the time
url_for needed it….
And then I realized it was because I had a
@url variable in my own controller action. And then I went to bed.
Most of the time I really love how dynamic and open Ruby is as a language, but sometimes private instance variables are just what you’d like to have had.