# Forms, Values, and Multiple Models question

**URL:** <https://www.ruby-forum.com/t/forms-values-and-multiple-models-question/121917>\
**Category:** Rails\
**Created:** [December 2, 2007, 9:47pm UTC](https://www.ruby-forum.com/t/forms-values-and-multiple-models-question/121917 "2007-12-02T21:47:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmiller3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f19dbf/32.png) [@dmiller3](https://www.ruby-forum.com/u/dmiller3)\
**Post date:** [December 2, 2007, 9:47pm UTC](https://www.ruby-forum.com/t/forms-values-and-multiple-models-question/121917/1 "2007-12-02T21:47:18Z")

</div>

Hi Everyone–

First the details…I have two models at the moment, member and  
account, which have the following relationship:

class Member \< ActiveRecord::Base

# Relationship between member and account

has\_one :account  
end

class Account \< ActiveRecord::Base

# Relationship between account and member

belongs\_to :member

end

Member has a bunch of attributes (first\_name, last\_name, address, etc.),  
and account has user\_name, password, and email.

An administrator will create the members, and members will not be  
allowed to create their own accounts initially. But that functionality  
may be needed later on so it seemed like a good idea to keep them  
separate.

Now for the questions.

I have created a form for adding new members and it works fine. But how  
would I set the values of the account with a user\_name (first letter of  
first name + lastname), and email address (which would be included in  
the form but is not an attribute of member)? I have watched the  
projects/tasks railscast several times on how to deal with multiple  
models in one form, but I don’t quite get it…like how to use the  
“fields\_for” without a for loop and the whole ‘builds’ concept. Is that  
functionality a standard part of rails? Every resource I’ve come across  
regarding forms and multiple models points to that same example, so it  
really isn’t helping much.

Unfortunately this is the most complicated part of my application, but I  
really need to get this working. Any suggestions would be greatly  
appreciated, including ‘you should not do it that way, it’s better  
to…’.

Thanks,  
Damonica
