Reputation: 1065
I'm running rails 5, upgraded from 4.2.x
In the console and when running methods that fail, the error doesn't show the line number, I only get to see:
Traceback (most recent call last):
NoMethodError (undefined method `[]' for nil:NilClass)
I made sure development.rb has:
config.log_level = :debug
My gemfile:
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
What should I change so I get to see line where error occurs?
Upvotes: 4
Views: 1531
Reputation: 1914
If you do something like this in the console:
begin
your_method_call
rescue => e
puts e.backtrace
end
You will be able to rescue the exception and print the backtrace. You don't have to puts
it, you can do whatever you want with the backtrace, but you get the idea.
Hope this help.
Upvotes: 5