本文介绍了ActiveRecord SQL查询未记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直面临一个奇怪的问题,其中ActiveRecord查询未在终端或Rails控制台中记录(使用 ActiveRecord :: Base.logger = Logger.new(STDOUT)).

I have been facing a weird problem for some time, wherein ActiveRecord queries are not getting logged in the terminal, or in the Rails console (using ActiveRecord::Base.logger = Logger.new(STDOUT)).

这是我得到的例外:

Could not log "sql.active_record" event. NameError: undefined
local variable or method `s'
for # ActiveSupport::Notifications::Event:0x007f9ae02a60c0.

我尝试了一些操作,包括重新安装Rails,但无济于事.

I tried out a few things, including reinstalling Rails, but to no avail.

除了想知道为什么会发生这种情况之外,我无法检查由此对数据库触发的实际SQL查询.

Apart from wondering why this is happening, I’m unable to check the actual SQL queries fired against the database as a result.

推荐答案

此问题是由于在instrumenter.rb文件中插入了流浪(偶然)引起的.删除角色可以帮助我解决问题.我不确定为什么重新安装滑轨对我没有帮助.

This problem was due to a stray (and accidental) 's' being inserted in the instrumenter.rb file. Removing the character helped me fix the problem. I'm not sure about why reinstalling rails did not help me though.

这篇关于ActiveRecord SQL查询未记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 03:59