binding.pry 被 Rails 3 忽略
我正在尝试调试我的小应用程序,由于 AssociationTypeMismatch 而无法创建价格。因此,我挖掘、安装、观看 Railscast 和 Josh 的截屏视频,并深入研究 wiki。
我“cd”进入价格控制器,但失败了。我已经把 <% binding.pry %>;在提交代码之前进入 new.html 但 Rails 说“pry”方法是未知的。 pry 位于我更新的 Gemfile 中,我重新启动了服务器。
我将 binding.pry 放入 rates_controller.rb 的 create 方法中,Rails 愉快地轻松地通过它抛出我已经看到的错误,而不是我所期望的暂停等。
看看价格模型,我的经验不够,不知道我应该寻找什么。我在忽略什么?谢谢,萨姆
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.
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.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有完全相同的问题,我的解决方案是将 pry-remote 添加到我的 Gemfile 中,并调用 binding.remote_pry 而不是 binding.pry ,在当前项目中打开终端并执行pry-remote。调试愉快:)
I have the exact same problem, my solution was to add pry-remote to my Gemfile, and call binding.remote_pry instead of binding.pry, open the terminal at your current project and execute pry-remote. happy debugging :)
看来除了撬宝石之外,我还需要撬轨宝石。现在绑定.pry 已被识别。
It appears that in addition to the pry gem, I need the pry-rails gem as well. Now the binding.pry is recognized.
您可以在绑定之前
require 'pry'
而不是安装 pry-rails :-)Instead of installing pry-rails you could just
require 'pry'
before the binding :-)