gpt4 book ai didi

ruby-on-rails - rails 5 : rails c doesn't show line number on error

转载 作者:行者123 更新时间:2023-12-04 13:22:38 26 4
gpt4 key购买 nike

我正在运行 Rails 5,从 4.2.x 升级

在控制台和运行失败的方法时,错误
不显示行号,我只能看到:

Traceback (most recent call last):
NoMethodError (undefined method `[]' for nil:NilClass)

我确保 development.rb 具有:
config.log_level = :debug

我的 gem 文件:
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

我应该更改什么才能看到发生错误的行?

最佳答案

如果你在控制台中做这样的事情:

begin
your_method_call
rescue => e
puts e.backtrace
end

您将能够挽救异常并打印回溯。你不必 puts它,你可以用回溯做任何你想做的事情,但你明白了。

希望这有帮助。

关于ruby-on-rails - rails 5 : rails c doesn't show line number on error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48255515/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com