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, ruby on rails, script console, sql