Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3606326
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:14:04+00:00 2026-05-18T21:14:04+00:00

Is there any gem which works on Rails 3 that can show which part

  • 0

Is there any gem which works on Rails 3 that can show which part of my code generated which SQL query?

On Rails 2.3 there was plugin called query_trace, but it doesn’t seem to work on Rails 3, it generates following error:

alias_method': undefined method `log_info' for class `ActiveRecord::ConnectionAdapters::AbstractAdapter' (NameError)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:14:04+00:00Added an answer on May 18, 2026 at 9:14 pm

    QueryTrace doesn’t work as-is because many changes were made in Rails 3 esp in the area of ActiveRecord.

    So, hacking around, I made it work like this:

    You just need the 2 files below in the locations mentioned. Then restart the web server.
    After the SQL, you should see Called from: in a console (magenta on white) and log file

    In /vendor/plugins/query_trace/lib/query_trace.rb

    module QueryTrace
      def self.append_features(klass)
        super
        klass.class_eval do
          unless method_defined?(:log_info_without_trace)
            alias_method :log_info_without_trace, :sql
            alias_method :sql, :log_info_with_trace
          end
        end
      end
    
      def log_info_with_trace(event)
        log_info_without_trace(event)
        logger.debug("\e[1m\e[35m\e[1m\e[47mCalled from:\e[0m " + clean_trace(caller[2..-2]).join("\n "))
      end
    
      def clean_trace(trace)
        Rails.respond_to?(:backtrace_cleaner) ?
          Rails.backtrace_cleaner.clean(trace) :
          trace
      end
    end
    

    In /vendor/plugins/query_trace/init.rb

    require 'query_trace'
    
    class ::ActiveRecord::LogSubscriber
      include QueryTrace
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any gem or plugin which can be used to send push alerts
Is there any gem/plugin for ruby on rails which gives the ability to define
Is there any ruby gem/ rails plugin available for parsing the resume and importing
Is there any tool to convert plugin to gem and vice versa.
Is there any way I can set a formatter on models that will convert
Is there any good gem for record caching for rails 3.2 ?. I tried
Is there any way we can fetch X509 Public Cetrificates using c# from AD
I've written a gem that looks in config/ for a config file. This works
I'm using daemons gem with Rails in addition to daemon_generator plugin. I'm getting this
Is there any functional difference in Python between a try statement and an if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.