Show generated SQL in Rails 3 console

1 · Seth Vargo · April 20, 2011, midnight
Have you ever wanted to see the resulting SQL of a query in Rails console? Well, unfortunately there's not really an 'easy' way to do this, other than hacking the console, so here we go. Fire up your Rails console. I'm using Rails 3, but this should would in <3: $ rails c Loading development environment (Rails 3.0.7) >> _ Cool, awesome, great. Now, we need to tell Rails console that we want to show what's being logged: $ rails c Loading development environment (Rails 3.0.7) >> ActiveRecord::Ba...