Possible to see what actual SQL queries Rails invokes when using console script?

Posted by randombits on Stack Overflow See other posts from Stack Overflow or by randombits
Published on 2010-05-29T17:37:01Z Indexed on 2010/05/29 17:42 UTC
Read the original article Hit count: 185

Filed under:
|

Sometimes I like to pop open the console script that comes with Rails to test small excerpts of code. That code normally involves some more involved ActiveRecord queries. Although not an expert in ActiveRecord, I'm proficient with SQL and want to see what it's translating underneath the hood for efficiency purposes. This will help me refactor or rethink how I'm writing my app if it looks inefficient. Now when the query is in the actual application itself, it all shows up in logs. Ad-hoc ActiveRecord queries in the console do not though. Anyway to change that behavior?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby