问题
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