Rails3 console : how to get actual sql statements

In rails 2.3.5 world I get to see all the sql statements on my
console. Thanks to following line of code in my ~/.irbc

Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))

However above code does not do its magic in rails3 world.

In rails3 what do I need to do to see sql statements in my rails

All I know is that RAILS_ENV is now Rails.env and RAILS_DEFAULT_LOGGER
is now Rails.logger

Maybe this helps you to find the solution :slight_smile:

Other than that I usually open a second Terminal window and do a

tail -f log/development.log

there I see the SQL statements which I evoked from the console.
Usually even color coded.

Here there is a tip:

In order to make it work for both Rails 2 and Rails 3, my ~/irbrc looks

require ‘logger’
if ENV.include?(‘RAILS_ENV’)&&
Object.const_set(‘RAILS_DEFAULT_LOGGER’, Logger.new(STDOUT))
ActiveRecord::Base.logger = Logger.new(STDOUT)

…not sure though if there is a better way to do that… bye.

(For Rails 3)

I have this in my development.rb environment file:

#log ActiveRecord
ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?