Engaging Social Software Blog

Icon

Its about engaging.

SQL output in your script controller

Ever found you needed to debug an activerecord query and wanted to see the SQL it was producing in the script/console. Well now you can.

If you want to see the sql output while you are in script/controller add this to your .irbrc file:

if ENV.include?(‘RAILS_ENV’) && !Object.const_defined?(‘RAILS_DEFAULT_LOGGER’)
require ‘logger’
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end

Thanks to ‘Scient|wrk’ on #rubyonrails for this one.

Advertisement

Filed under: Social Software elss08, , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.