【问题标题】:TypeError - Profile is not a class in rails 5TypeError - Profile不是rails 5中的类
【发布时间】:2018-11-09 19:48:46
【问题描述】:

突然之间,这个模型开始给我这个错误:

错误信息:

TypeError at /sv/dashboard
Profile is not a class

我不知道如何调试它,因为服务器日志只显示相同的错误而没有堆栈跟踪。

我正在运行rails 5.0.6

任何想法我应该如何解决或调试这个?

【问题讨论】:

  • 你说的突然是什么意思?你有什么改变吗?您如何在仪表板中调用 Profile 实例?
  • 如果你给它起不同的名字,它会起作用吗?喜欢 Profile2
  • @sovalina 我没有改变任何东西。
  • @coorasse 我尝试将类重命名为 UserProfile,但仍然遇到相同的错误,但类名已更改。
  • 你有 ApplicationRecord 模型吗?

标签: ruby-on-rails class ruby-on-rails-5 typeerror


【解决方案1】:

问题似乎是我在项目内部定义了一个名为ProfilesController 的控制器,但在Api 范围内,它与::ProfilesController 发生冲突:

class Api::ProfilesController
end

删除/重命名这个类及其路由解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-08
    • 2019-11-06
    • 2020-09-10
    • 2015-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多