4

rails console by default boots with context.back_trace_limit=16, which can be changed to whatever you want simply by typing context.back_trace_limit=n. The problem is you have to type it each time you boot rails c. Where do I change the context.back_trace_limit permanently? Some more reading on rails console configuration appreciated.

medik
  • 1,174
  • 12
  • 17

1 Answers1

7

You have to create/edit your ~/.irbrc with the following:

IRB.conf[:BACK_TRACE_LIMIT]= 20

To be taken into account:

  • The options must be uppercased
  • This option is changing not only the rails console, but the normal "irb" behavior (the rails console uses irb to run)
  • This setting is global, and not per project

Reference http://rakeroutes.com/blog/customize-your-irb/

Update for Rails 5

In Rails 5 the command context.back_trace_limit=20 will fail.

In the console you need to use the command conf.back_trace_limit = 10 for the current session.

For permanent changes, writing IRB.conf[:BACK_TRACE_LIMIT]= 20 in your ~/.irbrc is still valid.

You can see the current settings by calling conf

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
Fer
  • 3,247
  • 1
  • 22
  • 33
  • 2
    Works perfectly, thanks! Could you share where do you know about it from? – medik Oct 10 '14 at 09:46
  • 2
    This no longer works on Rails5. The `wtf?` method that comes with `pry` can help, but only gets you ten instead of one. – b264 Jun 21 '16 at 18:50