Enable stack dump on exception in Rails console
I found a solution myself.
Apparently, I was in need of the command wtf?
that comes with pry.
[7] project » p.known_attributes
NoMethodError: undefined method `foo' for #<Bar:0x007f871fd12a38>
from /[...]/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:436:in `method_missing'
[8] project » wtf?
Exception: NoMethodError: undefined method `foo' for #<Bar:0x007f871fd12a38>
--
[... stack dump ...]
[9] project »
When there's an error in console you should see something like this
$ rails c
Loading development environment (Rails 4.0.0)
irb(main):001:0> no_method
NameError: undefined local variable or method `no_method' for main:Object
from (irb):1
from /Users/michal/Projects/tennisliga/.gems/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /Users/michal/Projects/tennisliga/.gems/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /Users/michal/Projects/tennisliga/.gems/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
What's the problem with it? You don't see the stack trace?
EDIT: If you're using pry and would like to see more stack trace, refer to pry wiki Short example (show all lines)
Pry.config.exception_handler = proc do |output, exception, _pry_|
output.puts "#{exception}"
output.puts "#{exception.backtrace}"
end