Erik's Engineering

something alliterative

I'm not sure why this didn't occur to me sooner.  Most folks customize their irbrc file with tools to add features.  Why not use it to add helpers for things you do all the time?  I find myself loading up an example user record all the time, so I ginned up the following and stuck it in my .irbrc

It's a bit more convoluted than you'd normally expect, but by dancing around the subject a bit I made it so that this will compile just fine even if User isn't defined or doesn't support find_by_email.  I don't want irb/console to refuse to start because something isn't defined.

I just thought of this, so I'm not sure where it's going yet.  I'm going to be looking out for other opportunities to do this and thinking about how I might make it easier.  Perhaps a gem that would recognize if you were doing a Rails console session and load an application-specific irb helper file?

Published on 20/08/2011 at 16h14 under , . Tags ,

Powered by Typo – Thème Frédéric de Villamil | Photo Glenn