Showing SQL in script/console


#1

Is there an easy way to display the SQL in script/console (similar to
what is done in development.log)? The following works but it’s ugly:

$ script/console
Loading development environment.

class ActiveRecord::ConnectionAdapters::AbstractAdapter
def logger= (logr)
@logger = logr
end
end
=> nil

ActiveRecord::Base.connection.logger = Logger.new(STDOUT)
=> #<Logger:0x866a89f4 @level=0, @progname=nil,
@logdev=#<Logger::LogDevice:0x866a7f7c @filename=nil,
@mutex=#<Logger::LogDevice::LogDeviceMutex:0x865c1c34
@mon_entering_queue=[], @mon_count=0, @mon_owner=nil,
@mon_waiting_queue=[]>, @dev=#IO:0x817acafc, @shift_size=nil,
@shift_age=nil>, @formatter=nil,
@default_formatter=#<Logger::Formatter:0x866a8814
@datetime_format=nil>>

Jeremy