Revision: 37884
Updated Code
at February 7, 2011 22:27 by batamire
Updated Code
# for rails 2 if ENV.include?('RAILS_ENV') if !Object.const_defined?('RAILS_DEFAULT_LOGGER') require 'logger' Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT)) end def sql(query) ActiveRecord::Base.connection.select_all(query) end # for rails 3 elsif defined?(Rails) && !Rails.env.nil? if Rails.logger Rails.logger = Logger.new(STDOUT) ActiveRecord::Base.logger = Rails.logger end end
Revision: 37883
Updated Code
at December 19, 2010 22:09 by batamire
Updated Code
# execute this line in rails console ActiveRecord::Base.logger = Logger.new(STDOUT) # or paste this in ~/.irbrc # works for both Rails2 and Rails3 require 'logger' if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT)) else ActiveRecord::Base.logger = Logger.new(STDOUT) end
Revision: 37882
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 19, 2010 01:07 by batamire
Initial Code
# just execute this line ActiveRecord::Base.logger = Logger.new(STDOUT)
Initial URL
Initial Description
Initial Title
SQL log in Rails console
Initial Tags
sql, rails, log
Initial Language
Rails