Last active
September 25, 2015 09:08
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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