Rails SQL插入语句不会显示在控制台中 [英] Rails SQL insert statements not showing up in console
问题描述
我的终端用于显示SQL表插入语句(默认情况下应为),现在它不会。其他所有内容(例如,GET请求,本地服务器启动信息或作业完成通知)都会正常显示。
My terminal used to display SQL table insert statements (as it should by default), and now it doesn't. Everything else - for example, GET requests, or local server startup info, or job completion notifications - appear as normal.
对于我的生活,我不知道这是什么问题。我一直在寻找很长时间,不能找出任何理由,这将发生。
For the life of me, I can't figure out what the problem could be. I've been searching for a long time and can't figure out any reason this would happen. Do you have any ideas to point me in the right direction?
推荐答案
把它放在你的.irbrc或.pryrc中您的主目录
Put this in either in your .irbrc or .pryrc in your home directory
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
您应该开始看到在rails控制台中执行的sql语句。
希望这有助于
You should start to see the sql statements executing in the rails console. Hope this helps
这篇关于Rails SQL插入语句不会显示在控制台中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!