MPa*_*ons 11 ruby-on-rails exception ruby-on-rails-4
当我按照教程时,我正在关注rails教程书并使用c9.io web IDE.在处理我的示例应用程序时,我注意到在开发模式下页面上没有显示异常.此外,异常堆栈跟踪也未记录log/development.log
.这种困境使得我的代码中的错误调试变得困难.
错误 development.log
Completed 500 Internal Server Error in 116ms (ActiveRecord: 2.3ms)
Run Code Online (Sandbox Code Playgroud)
我已经尝试/研究过的
config.log_level = :debug
(在config/environments/development.rb中)config.consider_all_requests_local = true
配置/环境/ 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
Run Code Online (Sandbox Code Playgroud)
请记住,我对试图找到抛出异常的解决方案的答案不感兴趣.我只是想启用异常堆栈跟踪,以便我自己调试问题.
的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
Run Code Online (Sandbox Code Playgroud)
与此同时,我能够找到我的案例中问题的根源,尽管仍然不是解决方案。
我使用该rollbar-gem
扩展能够在生产中发布错误,这实际上似乎吸收了开发中的所有错误日志(即使它已被手动禁用)。因此,删除 gem 和所有代码使我可以再次访问我的日志。
我在 gems 页面上发布了一个关于此问题的问题。
您没有在 中运行该应用程序development
。rails s
Rails 应用程序可以使用(缩写)在本地运行rails server
。确保您已将RAILS_ENV
或等效设置为development
.