Autoloading ActiveRecord Associations in the Console

August 24th, 2007 1 Comment »

So, want to automagically load associations in script/console? I know I do. This little snippet did the trick, I got it here so have fun and don’t break anything!


# override the console's current behavior of not loading things automatically
class ActiveRecord::Associations::AssociationProxy
  def inspect
    load_target unless loaded?
    @target.inspect
  end
end