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

On Wed, Mar 9, 2011 at 7:32 AM, Peter D Bethke [email protected]
wrote:

I’m interested in just outputting the SQL from a AR find() construct to the page

  • without having to look at the console.

Take a look at this gem:

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

Handy for a number of reasons :slight_smile:


Hassan S. ------------------------ [email protected]
twitter: @hassan

On Wed, Mar 9, 2011 at 11:32 PM, Peter D Bethke
[email protected]wrote:

use .to_sql


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs