轨道上调试控制台视图ActiveRecord的sql语句 [英] Rails view activerecord sql statements on debug console

查看:90
本文介绍了轨道上调试控制台视图ActiveRecord的sql语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的Rails 3.2的应用程序调试的宝石。

I am using debugger gem in my Rails 3.2 application.

我如何查看活动记录方法产生的SQL语句调用调试控制台上?

How do I view the resulting SQL statement of active record method calls on the debug console?

有关,例如:如果我在调试控制台上运行 Product.all 它打印出的所有产品。我也想看看选择从产品*?为好。这可能吗?

For eg: If I run Product.all on the debug console it prints out all the products. I would also like to see the "Select * from Products" as well. Is this possible?

推荐答案

是的,你赌 - 就在你的命令执行这样的:

Yep, you bet - just run this before your commands:

ActiveRecord::Base.logger = Logger.new(STDOUT)

这篇关于轨道上调试控制台视图ActiveRecord的sql语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆