永久设置 rails 控制台堆栈回溯限制 [英] set rails console stack backtrace limit permanently
问题描述
rails 控制台
默认使用 context.back_trace_limit=16
启动,只需输入 context.back_trace_limit=n
即可更改为您想要的任何内容代码>.问题是每次启动 rails c
时都必须输入它.我在哪里永久更改 context.back_trace_limit
?阅读更多有关 rails 控制台配置的文章表示赞赏.
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.
推荐答案
您必须使用以下内容创建/编辑您的 ~/.irbrc
:
You have to create/edit your ~/.irbrc
with the following:
IRB.conf[:BACK_TRACE_LIMIT]= 20
需要考虑:
- 选项必须大写
- 这个选项不仅改变了rails 控制台,但正常的irb"行为(rails 控制台使用irb 运行)
- 此设置是全局的,而不是每个项目
参考 http://rakeroutes.com/blog/customize-your-irb/
Rails 5 更新
在 Rails 5 中,命令 context.back_trace_limit=20
将失败.
In Rails 5 the command context.back_trace_limit=20
will fail.
在控制台中,您需要对当前会话使用命令 conf.back_trace_limit = 10
.
In the console you need to use the command conf.back_trace_limit = 10
for the current session.
对于永久性更改,在 ~/.irbrc
中写入 IRB.conf[:BACK_TRACE_LIMIT]= 20
仍然有效.
For permanent changes, writing IRB.conf[:BACK_TRACE_LIMIT]= 20
in your ~/.irbrc
is still valid.
您可以通过调用conf
这篇关于永久设置 rails 控制台堆栈回溯限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!