我有一个rails 4应用程序,我想查看在我的应用程序中执行的sql查询。
在我的config / environment / development.rb中:
config.log_level = :debug
但是不足以显示我的rails应用程序生成的查询。
$ rails -v
Rails 4.1.1
$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
当我启动rails服务器时,不显示查询。
$ rails s
=> Booting WEBrick
=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2014-06-21 13:55:18] INFO WEBrick 1.3.1
[2014-06-21 13:55:18] INFO ruby 2.1.2 (2014-05-08) [i686-linux]
[2014-06-21 13:55:18] INFO WEBrick::HTTPServer#start: pid=6623 port=3000
I, [2014-06-21T13:55:21.869432 #6623] INFO -- : Started GET "/users/15" for 127.0.0.1 at 2014-06-21 13:55:21 -0300
I, [2014-06-21T13:55:21.869538 #6623] INFO -- : Started GET "/users/15" for 127.0.0.1 at 2014-06-21 13:55:21 -0300
Processing by UsersController#show as HTML
Parameters: {"id"=>"15"}
Rendered users/show.html.erb within layouts/application (9.1ms)
Completed 200 OK in 54ms (Views: 17.9ms | ActiveRecord: 4.1ms)
I, [2014-06-21T13:55:23.538983 #6623] INFO -- : Started GET "/assets/application.js" for 127.0.0.1 at 2014-06-21 13:55:23 -0300
I, [2014-06-21T13:55:23.542594 #6623] INFO -- : Started GET "/assets/application.js" for 127.0.0.1 at 2014-06-21 13:55:23 -0300
I, [2014-06-21T13:55:23.579254 #6623] INFO -- : Started GET "/assets/application.css" for 127.0.0.1 at 2014-06-21 13:55:23 -0300
I, [2014-06-21T13:55:23.579456 #6623] INFO -- : Started GET "/assets/application.css" for 127.0.0.1 at 2014-06-21 13:55:23 -0300
以下是我正在寻找的一个例子:
User Load (0.003154) SELECT * FROM `users` WHERE (`users`.`id` = 1) - (user.rb, line 24)
有人对我需要做什么有所了解? 非常感谢!