[英]Rails - one form, validation in two models
I have a form for the registration of new users. 我有一个新用户注册表格。 In the form are these inputs: 这些输入的格式为:
All fields are required. 各个领域都需要。 The first 3 fields are in model_a and the last two in model_b . 前三个字段在model_a中 ,后两个字段在model_b中 。 In both models I have already prepared validation rules. 在这两个模型中,我已经准备了验证规则。
It should work this way: User make registration and into the table model_a will be saved first 3 fields, into the table model_b last two fields. 它应该以这种方式工作:用户进行注册并进入表model_a将保存前3个字段,进入表model_b的最后两个字段。
But how to set up the form this way? 但是如何以这种方式设置表格?
Take a look at Nested forms 看看嵌套表单
http://railscasts.com/episodes/196-nested-model-form-part-1 http://railscasts.com/episodes/196-nested-model-form-part-1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.