Forum: Ruby on Rails Form Validation with 2 models on form. Nubee Question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris (Guest)
on 2006-03-27 12:39
I have one form in which i enter Person data and Employee Data. A Person
and Employee model are used.  I am using a legacy schema, so this is

How do i use save the data while using rails form validation??  I only
want both models to save if they both save.

Controller :

This odviously doesnt work:

def create_employee_and_person
  employee =[:employee])
  person =[:person])
  employee.person = person

  if and

Any help would be greately appreciated
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris (Guest)
on 2006-03-27 12:44
I have found the answer here :

I need to check that each model is valid :

if model1.valid? and model2.valid?
Ddffdd431166f9abb724004bdbe56f8c?d=identicon&s=25 Lucifron (Guest)
on 2006-03-29 10:47
(Received via mailing list)
Chris-45 wrote:
> This odviously doesnt work:
> Any help would be greately appreciated
I'd use a transaction spanning both updates.

View this message in context:
Sent from the RubyOnRails Users forum at
This topic is locked and can not be replied to.