Skip to content

Instantly share code, notes, and snippets.

@joeyAghion
Last active September 25, 2015 09:08
Show Gist options
  • Save joeyAghion/897691 to your computer and use it in GitHub Desktop.
Save joeyAghion/897691 to your computer and use it in GitHub Desktop.
convenience methods for logging SQL and Mongo queries to rails console, and issuing SQL queries directly
def log_to_console
ActiveRecord::Base.logger = Logger.new(STDOUT)
reload!
end
def sql(query)
ActiveRecord::Base.connection.select_rows(query)
end
def log_mongo_to_console
Mongoid.logger = Logger.new(STDOUT)
Moped.logger = Mongoid.logger
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment