irb, Rails, GuessMethod, and some magic new to me
I was looking at the code for Giles Bowkett’s utility_belt gem, and came across something I wish I had known about ages ago. There’s a way to execute some code in an .irbrc after everything else when the irb session starts (technically, when the context changes). The problem with GuessMethod and Rails was that GuessMethod can’t load first. Problem solved.
So now my .irbrc has this line to include GuessMethod in a way that works with script/console:
IRB.conf[:IRB_RC] = Proc.new { require 'guessmethod' }
Of course, if you’re using that IRB.conf[:IRB_RC] for something else (like using utility_belt), something’s going to overwrite something.
Anyway, I’ve finally just given up and wrapped my entire .irbrc in a big unless:
unless $0 == 'script/server'
I’m confused as to why script/server loads .irbrc for every request, but at least this mitigates that issue a bit. (As an aside, can someone tell me why it does that?)