使用一个模型在一种表单中创建多个记录 - 没有嵌套表单或任何其他内容

发布于 2024-10-28 08:55:08 字数 208 浏览 7 评论 0原文

你好 我搜索了一篇不错的文章,向我展示了如何使用一种形式将多个数据创建到一个模型中。我只发现真正先进的嵌套表单具有许多我认为我不需要的功能。

有人可以指导我如何做到这一点吗?

我有这两个型号。 产品价格众多 属于产品的价格

现在我想做一个表单,可以通过一个操作为每种产品创建价格。也许有一个很好的教程,但我找不到它......

提前致谢。

Hi
I've searched for a nice tut showing me how I can create multiple data into one single model with one form. I only find really advance nested forms with a lot of functionality that I believe I don't need.

Can someone give me a direction on how to do this.

I have these two models.
Products with many prices
Prices that belongs to products

Now I want to do a form that can create prices for every product in one single action. Maybe there is a nice tutorial out there on this, but I can't find it...

Thanks in advance.

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

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

发布评论

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

评论(1

橙幽之幻 2024-11-04 08:55:08

您需要嵌套表单,尽管它们不必很复杂。

请参阅相关的 Railscast 以获取对这些内容的详细介绍。 http://railscasts.com/episodes/196-nested-model-form -第1部分

You want nested forms, though they don't have to be complicated.

See the relevant Railscast for a great introduction to these. http://railscasts.com/episodes/196-nested-model-form-part-1

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