使用一个模型在一种表单中创建多个记录 - 没有嵌套表单或任何其他内容
你好 我搜索了一篇不错的文章,向我展示了如何使用一种形式将多个数据创建到一个模型中。我只发现真正先进的嵌套表单具有许多我认为我不需要的功能。
有人可以指导我如何做到这一点吗?
我有这两个型号。 产品价格众多 属于产品的价格
现在我想做一个表单,可以通过一个操作为每种产品创建价格。也许有一个很好的教程,但我找不到它......
提前致谢。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要嵌套表单,尽管它们不必很复杂。
请参阅相关的 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