Rails NoMethod 调用动态属性查找时出错
我目前正在开发一个应用程序。在此应用程序中,我创建了一个 Person 模型,并使用了 Rail 的动态属性查找功能。在 Person 模型中,我有一个名为 uid 的属性,因此我调用 Person.find_by_uid(某个数值)。这在我的开发模式下运行良好,并且该应用程序完全正常运行。然而,一旦我将此应用程序部署到heroku。应用程序失败,日志抱怨 NoMethodError (# 的未定义方法`find_by_uid'):
我一直在寻找所有地方,但仍然无法找到问题。我尝试在Person模型下定义方法find_by_uid,仍然不起作用。
我想知道是否有人有类似的经历或知道如何解决这个问题?
提前非常感谢!
I am currently working on an app. In this app, I created a Person model and I was using rail's dynamic attribute find feature. In the Person model I have an attribute called uid, so I was calling Person.find_by_uid(some numerical value). This worked fine in my development mode and the app was totally functioning. However, once I deployed this app to heroku. The app failed and the log complains about NoMethodError (undefined method `find_by_uid' for #):
I have been looking all places, but still unable to track down the problem. I tried to define the method find_by_uid under the Person model, and still does not work.
I was wondering if anyone has had similar experience or knows how to solve this issue?
Thank you very much ahead of the time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试在heroku(heroku rake db:migrate)中运行迁移?最能证明的是,该属性不在heroku 数据库中,因此您没有该动态方法。
Did you try running the migrations in heroku (heroku rake db:migrate)? Most provably that attribute is not in the heroku data base so you don't have that dynamic method.
我遇到了同样的问题。
heroku restart
救了我。I ran into the same problem.
heroku restart
has saved me.