Skip to content

Instantly share code, notes, and snippets.

@andreif
Forked from ches/gist:630625
Created July 25, 2011 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreif/1103816 to your computer and use it in GitHub Desktop.
Save andreif/1103816 to your computer and use it in GitHub Desktop.
.irbrc for logging goodies like SQL/Mongo queries to $stdout if in Rails 3 console
# .irbrc to log goodies like SQL/Mongo queries to $stdout if in Rails 3 console
if defined?(Rails) && Rails.respond_to?(:logger)
require 'logger'
Rails.logger = Logger.new($stdout)
if defined?(Mongoid)
Mongoid.logger = Rails.logger
end
end
@andreif
Copy link
Author

andreif commented Jul 25, 2011

Pop this snippet in your ~/.irbrc to show the raw JavaScript queries that Mongoid is running as you play with your app in the Rails console (and/or SQL, if you’re using ActiveRecord). Formatting isn’t great for Mongo queries, but it’s helpful nonetheless.
http://crumbtrail.chesmart.in/post/1334264255/handy-bits-for-mongoid-with-rails-3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment