无法逃脱下一个使用撬轨的评估



嗨,我安装了Pry来进行一些很棒的调试,以前也让它工作过,但当我用"next"进入代码时,我会收到以下错误:

SyntaxError: (eval):2: Can't escape from eval with next

正在使用的代码:

def create
    binding.pry
    build_resource(sign_up_params)
    if resource.save
      yield resource if block_given?
      if resource.active_for_authentication?
        set_flash_message :notice, :signed_up if is_flashing_format?
        sign_up(resource_name, resource)
        respond_with resource, :location => after_sign_up_path_for(resource)
      else
        set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
        expire_data_after_sign_in!
        respond_with resource, :location => after_inactive_sign_up_path_for(resource)
      end
    else
      clean_up_passwords resource
      respond_with resource
    end
  end

其他人有这个问题吗?

请确保安装"撬导航"宝石。

我也犯了同样的错误,因为我假设导航命令包含在"撬轨"宝石中。

在Gemfile中添加gem 'pry-nav',然后运行bundle install

您现在可以使用pry-byebug gem(对于Ruby>=2.0)或pry-debugger gem(用于Ruby<=1.9)

在您的Gemfile:中与pry宝石一起使用

# Gemfile
gem 'pry'
gem 'pry-byebug'

我也遇到过类似的问题,在我的案例中,问题得到了解决,因为我需要这些宝石。例如:

group :development, :test do
  ...
  gem 'pry',                                require: true
  gem 'pry-byebug',                         require: true
  gem 'pry-doc',                            require: true
  gem 'rspec-rails',                        require: false
  ...
end

这就是解决问题的方法。甚至这里的答案对我都不起作用。

我不得不将require 'pry-byebug'添加到我的规范文件中!

我认为这里的问题是您正在块内调试,所以当您在块内时不能调用next

最新更新