Monday, February 9, 2009

Debugging -or- Lose the "Print Variable" Mentality

Thanks to Mischa Fierer at The Momoro Hoax for getting me off my duff to try out debugging with rails again. I'd not done anything since it didn't work for me in RadRails and XP/Vista. Now I'm on Linux and have no excuses.

Specifically, Use rails debugger ! A tutorial walked through the steps to get started. Look to the Rails Debugging Guide for more detailed learning when the time comes.

Friday, February 6, 2009

Force Exceptions in Migrations

A couple of times now, I've run a data update migration that failed and didn't throw an Exception. So I ended up with bad data in the system and no knowledge of the problem until the application bombed out in production.

Instead, use the '!' version of save when you do the updates. g.save! throws an exception on failure where g.save does not.

Thursday, February 5, 2009

Two Buttons - One Form

Create a form with two submit buttons. Label them each differently and Rails passes the name of the one that was pressed back in params['commit'].

Useful to have one button return to the listing view while having the other button save, but leave the input form open for more data.

Act to Advance

Try the new thing just when I read it. It will stay when it's a good thing.

Ten minutes with each of Autotest, FlexMock, Factory Girl, and Shoulda improved my testing immeasurably.

And not half as painful as I ever expected.

rubygems proxy URL

The proper format to set the proxy for 'gem' inside my corporate firewall is:

gem install xyz --http-proxy http://user:pass@proxy.domain.com:8080/

Must have the port for anything to work. Probably can put this in ".gemrc".