我在binding.pry或byebug上输入next跳到下一行。我使用step单步执行该过程。如何后退一行?
我一直在浏览文档,但没有找到。非常感谢您的帮助。谢谢。
发布于 2017-07-24 18:11:58
当您使用ByeBug时,您无法后退一步。
发布于 2018-08-31 16:29:10
您可以在binding.pry中使用up & down方法
请看这里:
Frame number: 0/64
From: /Users/johnmair/ruby/rails_projects/personal_site/app/controllers/posts_controller.rb @ line 7 PostsController#index:
5: def index
6: @posts = Post.all
=> 7: binding.pry
8: end
[1] pry(#<PostsController>)> show-stack
Showing all accessible frames in stack (65 in total):
--
=> #0 index <PostsController#index()>
#1 [method] send_action <ActionController::ImplicitRender#send_action(method, *args)>
#2 [method] process_action <AbstractController::Base#process_action(method_name, *args)>
#3 [method] process_action <ActionController::Rendering#process_action(*arg1)>
<... clipped ...>
[2] pry(#<PostsController>)> up
Frame number: 1/64
Frame type: method
From: /Users/johnmair/.rvm/gems/ruby-2.0.0-p0/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb @ line 4 ActionController::ImplicitRender#send_action:
3: def send_action(method, *args)
=> 4: ret = super
5: default_render unless response_body
6: ret
7: end
[3] pry(#<PostsController>)> 发布于 2018-05-01 17:48:28
折衷的解决方案是使用pry-moves重新执行以前的代码片段。
例如,如果您在Controller的操作中停止:
def index
list = Orders.for_user(current_user)
=> binding.pry
end现在你想知道为什么list是空的了吗?-你可以运行:
> debug Orders.for_user(current_user)看看那里发生了什么
为什么我们必须使用折衷方案?问题是ruby环境在每一步都不能保持系统的整体状态。大概是因为你仍然会使用外部系统(例如,通过API调用),这可能会改变它们的内部状态,而你不能自动“回滚”。
https://stackoverflow.com/questions/30062355
复制相似问题