Skip to content

Instantly share code, notes, and snippets.

View belt's full-sized avatar

Paul belt

View GitHub Profile
https://gist.github.com/belt/c8f7b1c45834ce6fa485
desc 'Create a db/extracted_data.sql file for a given entity'
namespace :db do
namespace :grep do
task associations: :environment do
obfuscate_sql if obfuscate
Rails.application.eager_load!
if dump_file_path.blank?
puts grep_associations_to_sql
@belt
belt / query_trace.rb
Created August 10, 2011 16:33
QueryTrace... ported to rails3
require 'term/ansicolor'
# yeilds a stacktrace for each SQL query
# put this file in config/initializers
class QueryTrace < ActiveSupport::LogSubscriber
include Term::ANSIColor
attr_accessor :trace_queries
def sql(event) #:nodoc:
return unless QueryTrace.enabled? && logger.debug? && Rails.env.development?