The important thing is that rails console use irb, and has access to the range of irb config options
$ rails c
Loading development environment (Rails 4.2.0)
>> conf
=> conf.ap_name="irb"
conf.auto_indent_mode=false
conf.back_trace_limit=16
.
.
.
And there it is: conf.back_trace_limit. So:
conf.back_trace_limit = 0
will effectively disable the backtrace for the current session, and output will be nice and concise:
>> MyModel.gnu
NoMethodError: undefined method `gnu' for MyModel:Class
or
>> obj.do_defective_math
ZeroDivisionError: divided by 0
To make things a bit more convenient, a function can be defined in ~/.irbrc. Something like:
def toggle_trace
if conf.back_trace_limit > 0
conf.back_trace_limit = 0
else
conf.back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
end
end
which can be called a console session to disable or enable the back trace as needed