在Rails 3.2中禁用说明
是否可以通过配置全局禁用Rails 3.2中的新解释function? 我正在使用activerecord-sqlserver-adapter 3.2.1,并且似乎有一些错误与gem的解释(显示计划)部分。
从http://weblog.rubyonrails.org/2011/12/6/what-s-new-in-edge-rails-explain/引用
新应用程序得到
config.active_record.auto_explain_threshold_in_seconds = 0.5
在
config/environments/development.rb
。 Active Record监视查询,如果超过该阈值,则将使用warn记录其查询计划。[…]
默认情况下,测试和生产环境中的阈值为
nil
,这意味着该function已被禁用。
所以只是设置
config.active_record.auto_explain_threshold_in_seconds = nil
您可以通过在config / environments / development.rb中设置config.active_record.auto_explain_threshold_in_seconds = nil
来禁用自动解释。
您应该注意,在Rails 4.0和4.1中已完全删除了config.auto_explain_threshold_in_seconds
。 在4.1中它会抛出一个完整的错误。
请参阅https://github.com/rails/rails/pull/9400/files
如果您升级,请注释掉该行。