Issues with relationships and multiple objects on one form

Hello,

  1. I have a form that edits a User and a Person at the same time. The
    controller is for the User. Everything works fine, except the fields
    that are populated by the Person fields lose state when validation
    fails. Do I use params to populate the user? I have tried a bunch of
    combinations with no luck.

  2. The same users table has an integer column called
    ‘primary_organization_id’, where Organization references many User
    records. The models are defined as:

class User < ActiveRecord::Base
belongs_to :primary_organization,
:class_name => ‘Organization’,
:foreign_key => ‘primary_organization_id’

class Organization < ActiveRecord::Base
has_many :primary_users,
:class_name => ‘User’,
:foreign_key => ‘primary_organization_id’

A select displays all Organizations on the User form, allowing the
relationship to be defined using the code:

Primary Organization <%= collection_select('user', 'primary_organization_id', @organizations, 'id', 'name') %>

When I create and save a new user everything works fine. When I open
the user to edit it, the relationship is correct, but when I try and
save existing user I get the error:

Unknown key(s): primary_organization_id

Any help would be greatly appreciated.

Thanks,
Dave