user984621
user984621

Reputation: 48453

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. 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.

But how to set up the form this way?

Upvotes: 1

Views: 451

Answers (1)

InternetSeriousBusiness
InternetSeriousBusiness

Reputation: 2635

Take a look at Nested forms

http://railscasts.com/episodes/196-nested-model-form-part-1

Upvotes: 1

Related Questions