Immediately evaluate multiple lines of code at same time in rails console when using pry?

僤鯓⒐⒋嵵緔 提交于 2021-02-08 10:00:39

问题


Suppose we have pry installed, open the rails console, and run

times = [1, 5, 10, 30, 72].sample(1)[0]
nums = *(1..72)
num_sample = nums.sample(times)

Evaluation stops after line 2 (since the output of the second line runs off screen and hence the console opens the output):

How can we get the console to not stop executing, but rather display the entirety of the output of one line before executing the next, that is, to execute all lines of code it receives? Is there any way to achieve this without removing the pry-rails gem?


回答1:


You can disable pry pager:

Disabling paging Permanently (in a .pryrc file)

Pry.config.pager = false

Temporarily (in a repl session)

pry_instance.config.pager = false


来源:https://stackoverflow.com/questions/63871606/immediately-evaluate-multiple-lines-of-code-at-same-time-in-rails-console-when-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!