本文介绍了binding.pry 被 rails 3 忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试我的小应用程序,因为 AssociationTypeMismatch 导致其无法创建价格.所以我挖掘了 pry、安装、观看 railscast 和 Josh 的截屏视频并深入到 wiki.

I'm trying to debug my little app failing to create a Price because of an AssociationTypeMismatch. So I dig out pry, install, watch railscast and Josh's screencast and dig into the wiki.

我cd"到价格控制器,但失败了.在提交代码之前,我已经将 <% binding.pry %> 放入 new.html 中,但 Rails 说 'pry' 方法是未知的.撬在我更新的 Gemfile 中,我重新启动了服务器.

I "cd" into the prices controller but that fails. I've put <% binding.pry %> into the new.html before the submit code but Rails says that the 'pry' method is unknown. pry is in my updated Gemfile and I restarted the server.

我将 binding.pry 放入我的prices_controller.rb 的create 方法中,Rails 愉快地通过它来抛出我已经看到的错误,而不是我期待的暂停等.

I put binding.pry into the create method of my prices_controller.rb and Rails happily breezes through it to throw the error I've already seen, not the pause, etc I was expecting.

看看价格模型,我的经验不足,不知道我应该寻找什么.我在看什么?谢谢,山姆

Looking at the Price model, I'm not experienced enough to know what I should be looking for. What am I overlooking? thanx, sam

推荐答案

看来除了 pry gem 之外,我还需要 pry-rails gem.现在可以识别 binding.pry.

It appears that in addition to the pry gem, I need the pry-rails gem as well. Now the binding.pry is recognized.

这篇关于binding.pry 被 rails 3 忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 22:08