由于某些原因,当我使用binding.pry设置一个断点时,程序会在一个完全不同的地方停止运行(而且外星正在寻找!)地点。我做错了吗?
Gemfile (简写)
gem "rails", "~> 4.1"
gem "pry"
gem "pry-rails"
gem "pry-doc"
gem "pry-stack_explorer"
gem "pry-byebug"场景
断点:
class SomeController < Application controller
before_filter :filter
...
def filter
assignment = SkillAssignment.where(day: selected_date).first
if assignment
@day_skill = assignment.skill
@day_description = @day_skill.description
end
binding.pry
end
end我登陆的地方(使用show-source__):
[1] pry(ActiveSupport::Callbacks::Filters::Before)> show-source
From: /home/yan-foto/workspaces/my-app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb @ line 156:
Owner: #<Class:ActiveSupport::Callbacks::Filters::Before>
Visibility: private
Number of lines: 16
def self.halting(next_callback, user_callback, halted_lambda, filter)
lambda { |env|
target = env.target
value = env.value
halted = env.halted
unless halted
result = user_callback.call target, value
env.halted = halted_lambda.call(target, result)
if env.halted
target.send :halted_callback_hook, filter
end
end
next_callback.call env
}
end发布于 2015-01-26 13:37:51
感谢“Manuel”和“Anthony”,我现在知道这个问题是由错误 in pry-byebug引起的。不幸的是,这个问题似乎没有在开发人员在GitHub中提到的一开始就得到解决。
目前的情况是,我几乎从来没有使用过撬-byebug,所以我觉得没有动力的人,我不使用的软件。:(
如果您想让binding.pry位于最后一行,一个简单的解决方法是编写如下内容:
def myMethod
# magic
binding.pry
1 + 1
endhttps://stackoverflow.com/questions/28150164
复制相似问题