Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see the SQL ActiveRecord generates?

I'd like to check a few queries generated by ActiveRecord, but I don't need to actually run them. Is there a way to get at the query before it returns its result?

like image 276
James A. Rosen Avatar asked Oct 28 '08 15:10

James A. Rosen


2 Answers

Both of these articles should help you do what you want.

http://weblog.jamisbuck.org/2007/1/8/watching-activerecord-do-it-s-thing

http://weblog.jamisbuck.org/2007/1/31/more-on-watching-activerecord

like image 90
jonnii Avatar answered Sep 23 '22 16:09

jonnii


i think it's buried in:

construct_finder_sql,

http://groups.google.com/group/rubyonrails-talk/browse_frm/thread/38c492e3939dd9bf/?pli=1

like image 38
Gene T Avatar answered Sep 21 '22 16:09

Gene T