Outputting SQL to page

Hi,

I'm interested in just outputting the SQL from a AR find() construct to the page - without having to look at the console. I tried doing this:

self.joins(...)\
        .select(...)\
        .where(...)\
        .order(...)\
        .to_s

thinking that it would output the sql as a string, but its just an AR object apparently. (note - I removed the particulars of the query for this example but they work fine and the query is visible in the console).

Any ideas? Newbie, obviously and working _really_ hard to embrace non-hand coded SQL. :slight_smile:

Thanks!

Peter

Take a look at this gem:

  http://wiki.github.com/josevalim/rails-footnotes

Handy for a number of reasons :slight_smile:

Hi,

I’m interested in just outputting the SQL from a AR find() construct to the page - without having to look at the console. I tried doing this:

self.joins(…)\

    .select(...)\

    .where(...)\

    .order(...)\

    .to_s

use .to_sql