binding.pry 被 Rails 3 忽略

发布于 2025-01-02 16:36:05 字数 376 浏览 3 评论 0原文

我正在尝试调试我的小应用程序,由于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

月亮坠入山谷 2025-01-09 16:36:05

我有完全相同的问题,我的解决方案是将 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 :)

这样的小城市 2025-01-09 16:36:05

看来除了撬宝石之外,我还需要撬轨宝石。现在绑定.pry 已被识别。

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

世态炎凉 2025-01-09 16:36:05

您可以在绑定之前 require 'pry' 而不是安装 pry-rails :-)

Instead of installing pry-rails you could just require 'pry' before the binding :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文