With query_trace enabled, the Rails logs will contain a partial stack trace for every executed SQL statement, making it easier to find where they are generated in your code.
Nathaniel Talbott, Mike Gunderloy
gem "query_trace-rails-3", "~> 0.1.1"