下次使用Pry-rails时无法逃脱eval

Sha*_*son 28 ruby-on-rails pry pry-rails

嗨我已经安装了Pry来做一些很棒的调试并且之前有它工作但是当我用'next'进入代码时我得到以下错误:

SyntaxError: (eval):2: Can't escape from eval with next
Run Code Online (Sandbox Code Playgroud)

正在使用的代码:

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
Run Code Online (Sandbox Code Playgroud)

其他人遇到过这个问题吗?

Aur*_*rte 50

请确保安装'pry-nav'宝石.

我有同样的错误,因为我假设导航命令包含在'pry-rails'宝石中.

添加gem 'pry-nav'您的Gemfile,然后运行bundle install.

  • 这个答案怎么不是到处都是? (6认同)
  • 在[pry-nav](https://github.com/nixme/pry-nav)页面上,现在建议使用[pry-byebug](https://github.com/deivid-rodriguez/pry-byebug) gem(对于Ruby> = 2.0)或[pry-debugger](https://github.com/nixme/pry-debugger)gem(对于Ruby <= 1.9). (4认同)

exm*_*axx 13

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

pry在Gemfile中将它与gem 一起使用:

# Gemfile
gem 'pry'
gem 'pry-byebug'
Run Code Online (Sandbox Code Playgroud)