Rails 4异常堆栈跟踪未在开发中显示 [英] Rails 4 exception stack traces don't show in development

查看:68
本文介绍了Rails 4异常堆栈跟踪未在开发中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注



development.log $ b中的错误
$ b

 在116毫秒内完成500个内部服务器错误(ActiveRecord:2.3ms)

我已经尝试过/研究过的




  • config.log_level =:debug (在config / environments / development.rb中)

  • config.consider_all_requests_local = true



  • 其他



config / environments / development.rb

  Rails.application.configure do 
#此处指定的设置将优先于config / application中的设置。 rb。

#在开发环境中,每个请求都会在
#上重新加载应用程序的代码。这会减慢响应时间,但是非常适合开发
#,因为在更改代码时不必重新启动Web服务器。
config.cache_classes = false

#不要急于在引导时加载代码。
config.eager_load = false

#显示完整的错误报告并禁用缓存。
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

#不管邮件发送者是否可以发送。
config.action_mailer.raise_delivery_errors = false

#将弃用通知打印到Rails记录器。
config.active_support.deprecation =:log

#如果存在挂起的迁移,则会在页面加载上引发错误。
config.active_record.migration_error =:page_load

#调试模式禁用资产的串联和预处理。
#此选项可能会导致大量复杂资产
#的视图渲染出现重大延迟。
config.assets.debug = true

#资产摘要可让您为所有资产设置远期的HTTP失效日期,
#仍然可以通过消化参数。
config.assets.digest = true

#在运行时提供资产时添加其他错误检查。
#检查未正确声明的链轮依赖关系。
#引发有用的错误消息。
config.assets.raise_runtime_errors = true

#因缺少翻译而引发错误
#config.action_view.raise_on_missing_translations = true
config.log_level =:debug
end

请记住,我对答案感兴趣尝试找到引发异常的解决方案。我只想启用异常堆栈跟踪,以便自己调试问题。



编辑2/25/2017



Gemfile

 来源'https://rubygems.org'

gem'rails','4.2.2'
gem'bcrypt','3.1.7'
gem'faker','1.4.2'
gem' carrierwave','0.10.0'
宝石'mini_magick','3.8.0'
宝石'fog','1.36.0'
宝石'will_paginate','3.0.7'
gem'bootstrap-will_paginate','0.0.10'
gem'bootstrap-sass','3.2.0.0'
gem'sass-rails','5.0.2'
gem'uglifier','2.5.3'
gem'coffee-rails','4.1.0'
gem'jquery-rails','4.0.3'
gem' turbolinks','2.3.0'
gem'jbuilder','2.2.3'
gem'sdoc','0.4.0',组::doc

组:development,:test做
gem'sqlite3','1.3.9'
gem'byebug','3.4.0'
gem'web-console','2.0.0.beta3'
gem'spring ','1.1.3'
end

group:test do
gem'minitest-reporters','1.0.5'
gem'mini_backtrace',' 0.1.3'
gem'guard-minitest','2.3.1'
end

group:production do
gem'pg','0.17.1 '
gem'rails_12factor','0.0.2'
gem'puma','3.1.0'
end


解决方案

尝试更新您的网络控制台gem。

 捆绑更新网络控制台


I'm following the rails tutorial book and using the c9.io web IDE as I follow the tutorials. While working on my sample application, I noticed that exceptions aren't being shown on the page in while in development mode. Additionally, the exception stack traces aren't being logged in log/development.log either. This predicament is making it difficult to debug errors in my code.

Error from application

Error in development.log

Completed 500 Internal Server Error in 116ms (ActiveRecord: 2.3ms)

What I've already tried / researched

  • config.log_level = :debug (in config/environments/development.rb)
  • config.consider_all_requests_local = true
  • this
  • that
  • the other

config/environments/development.rb

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
  config.log_level = :debug
end

Please keep in mind that I am not interested in answers that attempt to find a solution for the exception being thrown. I'm only looking to enable the exception stack traces so that I may debug the problem myself.

Edit 2/25/2017

Gemfile

source 'https://rubygems.org'

gem 'rails',                   '4.2.2'
gem 'bcrypt',                  '3.1.7'
gem 'faker',                   '1.4.2'
gem 'carrierwave',             '0.10.0'
gem 'mini_magick',             '3.8.0'
gem 'fog',                     '1.36.0'
gem 'will_paginate',           '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass',          '3.2.0.0'
gem 'sass-rails',              '5.0.2'
gem 'uglifier',                '2.5.3'
gem 'coffee-rails',            '4.1.0'
gem 'jquery-rails',            '4.0.3'
gem 'turbolinks',              '2.3.0'
gem 'jbuilder',                '2.2.3'
gem 'sdoc',                    '0.4.0', group: :doc

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
  gem 'puma',           '3.1.0'
end

解决方案

Try to update your web-console gem.

bundle update web-console

这篇关于Rails 4异常堆栈跟踪未在开发中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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