Rails 找不到首选项关联的有效模型

发布于 2025-01-10 07:03:58 字数 720 浏览 2 评论 0原文

我正在尝试将新记录添加到我的数据库中,但出现此错误: 输入图片此处描述

这是我的 schema.rb: 输入图片此处描述

这是我的创建方法: 输入图片此处描述

这是我添加新记录的表单:

在此处输入图像描述

参数发送正确,但是当我单击“上传”按钮时,没有任何反应,如果我尝试从 Rails 控制台添加记录,但出现第一张图像的错误。我是 RoR 的新开发者,有人可以帮助我吗?谢谢!

I'm trying to add new record to my DB, but I got this error:
enter image description here

This is my schema.rb:
enter image description here

And this is my method create:
enter image description here

And this is my form to add a new record:

enter image description here

The param is sending correctly, but when I click on Upload button, nothing is happen, and if I try to add the record from the rails console, I got the error of the first image. I'm a new dev of RoR, someone can help me please?, Thanks!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

赢得她心 2025-01-17 07:03:58

如果不查看相关模型及其关联,什么都不清楚,因为,似乎您的模型关联导致了此错误。
模型关联描述了模型之间的关系(如果是一对一、一对多等),称为继承,这是任何面向对象编程中非常重要的概念。这就是我们在 Rails 中实现它的方式
请仔细阅读此文档
它可能会帮助您更好地了解 Rails 关联。

Without looking at the related models and their associations nothing is clear, because, it seems like your model associations are causing this error.
Model associations depict the relations between models (if its one-one, one-many and such) known as inheritance, very important concept in any object oriented programming. this is the way we implement it in rails
Go through this documentation.
It might help you get better understanding of rails associations.

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