Logging Rails activity in script/console
February 01, 2007 00:53 (Sydney Australia), updated 5 days later
Update: Check out System-wide script/console logging for something a little more convenient.
Just found this nice little nugget:
if "irb" == $0
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
Chuck that into environment.rb and you’ll get log messages straight into your script/console when interacting with your models. If there was a way to tell if you were in the rails console within .irbrc you could do it system wide.
Can anybody else see a tryactiverecord.com in the making? Why_, you hear that?

Comments
Chad Humphries
I do something like this in my irbrc:
To test it out yourself add the above and the below to your .irbrc file.
Tim Lucas
Sweet, thanks Chad! I’ve used this in my .irbrc and it works a treat.
To comment on this article you must have javascript enabled.