我正在运行rails 5,从4.2.x升级
在控制台中以及运行失败的方法时,错误 没有显示行号,我只看到:
Traceback (most recent call last):
NoMethodError (undefined method `[]' for nil:NilClass)
我确保development.rb有:
config.log_level = :debug
我的宝石文件:
source 'https://rubygems.org'
gem 'rails', '5.1.2' # mothership
gem 'bootstrap-sass' # crutches
gem 'sass-rails' # Use SCSS for stylesheets
gem 'devise' # login/sessions
gem 'devise-i18n' # login/sessions
gem 'haml' # markup language
gem 'uglifier', '>= 1.3.0' # Use Uglifier as compressor for JavaScript assets
gem 'coffee-rails'
gem 'jquery-rails' # Use jquery as the JavaScript library
gem 'bcrypt', '~> 3.1.7' # Use ActiveModel has_secure_password
gem 'html5_validators'
gem 'execjs'
gem 'puma'
gem 'pg'
gem 'listen'
group :development do
gem 'rails_db'
gem 'hirb'
gem "better_errors"
gem "binding_of_caller"
end
group :production do
gem 'aws-sdk-rails'
gem 'rails_12factor'
end
我应该改变什么,以便看到发生错误的行?
答案 0 :(得分:1)
如果您在控制台中执行以下操作:
begin
your_method_call
rescue => e
puts e.backtrace
end
您将能够挽救异常并打印回溯。你没有puts
它,你可以用回溯做任何你想做的事,但你明白了。
希望得到这个帮助。