Forum: Rails deployment how to generate sql eports

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
727118bcddbd0a9fdbddb7fd8d485b57?d=identicon&s=25 Mondher Gatri (mgatri)
on 2009-11-09 09:04
Dear all,
I’m developing an application dedicated to generate statistical reports,
I would like that user after saving their stat report they save sql
queries too. To do that I wrote the following module:

module SqlHunter
    class ActiveRecord::ConnectionAdapters::AbstractAdapter

        @@queries = []
        cattr_accessor :queries
        def log_info_with_trace(sql, name, runtime)
         return unless @logger && @logger.debug?
        @@queries << sql
        alias_method_chain :log_info, :trace

in the controller I wrote that

sqlfile ="public/advancedStats/#{@dir_name}/advancedStatQuery.sql",
@queries = ActiveRecord::ConnectionAdapters::AbstractAdapter::queries
for query in @queries do
      sqlfile.write("#{query} \n")

I also modified Rails environment by adding this line:

ActiveRecord::Base.logger.level = Logger::DEBUG

This program is working and I can get queries but, all queries. In
contrast I need only the specific queries done by one user to generate a
stat report.

Is someone has any idea,

This topic is locked and can not be replied to.