Friday, August 17, 2012

Enable SQL stdout in Rails console


Edit or create .irbrc (or .pryrc if you're using pry) file in user home directory.  Add the following lines:
if defined?(Rails) && !Rails.env.nil?
puts '... ActiveRecord and ActiveResource Logger set to STDOUT'
logger = Logger.new(STDOUT)
ActiveRecord::Base.logger = logger
ActiveResource::Base.logger = logger
end

Then on your rails console, you should see the SQL statements being executed.







No comments:

Post a Comment

Note: Only a member of this blog may post a comment.