简体   繁体   English

Rails-一种形式,在两种模型中进行验证

[英]Rails - one form, validation in two models

I have a form for the registration of new users. 我有一个新用户注册表格。 In the form are these inputs: 这些输入的格式为:

  • name (model_a) 名称(model_a)
  • age (model_a) 年龄(model_a)
  • email (model_a) 电子邮件(model_a)
  • icq (model_b) icq(model_b)
  • skype (model_b) skype(model_b)

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? 但是如何以这种方式设置表格?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM