3 models in 1 template

hello,

I'd like to get user data in one template.

The relations are:
user has_one user_adress
user has_one user_account

The following template doesn't save any (valid) data. I think the
submit button doesn't work.
All 3 models should be validated when save is called.

<div class="shop-form">

  <%= error_messages_for 'user' %>
  <%= error_messages_for 'user_adress' %>
  <%= error_messages_for 'user_account' %>

  <fieldset>
    <legend>Please enter your data: </legend>

    <% form_for :user do |form| %>
        <label for="user_first_name">firstname:</label>
        <%= form.text_field :first_name, :size => 40 %>
      </p>
      <p>
        <label for="user_surname">surname:</label>
        <%= form.text_field :surname, :size => 40 %>
      </p>
      <p>
        <label for="user_birthdate">date of birth</label><br/>
        <%= date_select 'user', 'birthdate', :include_blank => true,
        :order => [:day, :month, :year], :start_year => 1900, :default
=> :blank %>
      </p>
      <p>
        <label for="user_email">email:</label>
        <%= form.text_field :email, :size => 40 %>
      </p>
      <p>
        <label for="user_username">username:</label>
        <%= form.text_field :username, :size => 40 %>
      </p>
      <p>
        <label for="user_password">password:</label>
        <%= form.password_field :password, :size => 40 %>
      </p>
      <p>
        <label for="user_password_confirmation">passwort
confirmation:</label>
        <%= form.password_field :password_confirmation, :size => 40 %>
      </p>
    <% end %>

  <br/>

    <legend>Your adress:</legend>
    <% form_for :user_adress do |form| %>
      <p>
        <label for="user_adress_street">street:</label>
        <%= form.text_field :street, :size => 40 %>
      </p>
      <p>
        <label for="user_adress_nr">number:</label>
        <%= form.text_field :nr, :size => 40 %>
      </p>
      <p>
        <label for="user_adress_postcode">postcode:</label>
        <%= form.text_field :postcode, :size => 40 %>
      </p>
      <p>
        <label for="user_adress_city">City:</label>
        <%= form.text_field :city, :size => 40 %>
      </p>
    <% end %>

  <br/>

    <legend>Your payment details:</legend>
    <% form_for :user_account do |form| %>
      <p>
        <label for="user_account_bank">credit institution:</label>
        <%= form.text_field :bank, :size => 40 %>
      </p>
      <p>
        <label for="user_account_bank_code">bank code:</label>
        <%= form.text_field :bank_code, :size => 40 %>
      </p>
      <p>
        <label for="user_account_account_number">account number:</

        <%= form.text_field :account_number, :size => 40 %>
      </p>
    <% end %>

  <br/>

  <%= submit_tag "Register", :class => "submit" %>
  </fieldset>

</div>

there's also a problem in my controller. Neither does it save anything
to the database nor validate the models.

The template is register.rhtml. I wrote it as you said.

  def register
    @user = User.new
  end

  def new
    if @user.save
      @user.adress = @user_adress
      @user.account = @user_account
      flash[:notice] = 'Registration was successful.'
      redirect_to :action => 'index'
    else
      render :action => 'register'
    end
  end

I forgot to say that the relations are dependent.

And not everyone does have an account. So, if there's nothing in the
account field, the account shouldn't be saved.

Thanks for your help, I got to the following working code. 2 more
questions after the code.

In the controller:

  def register
    @user = User.new(params[:user])
    @user.time_of_registration = Time.now
    @user.user_adress = UserAdress.new(params[:user_adress])
    @user.user_account = UserAccount.new(params[:user_account])
    if request.post? and @user.save
      flash[:notice] = 'Registration was successful.'
      redirect_to :action => 'login'
    end
  end

register.rhtml:

<div class="shop-form">

  <%= error_messages_for 'user' %>

  <fieldset>
    <legend>Please enter your data: </legend>

    <% form_for :user, @user do |form| %>
      <p>
        <label for="user_first_name">First name:</label>
        <%= form.text_field :first_name, :size => 40 %>
      </p>
      ...

      <% fields_for :user_adress, @user_adress do |fields| %>
        ...
      <% end %>

      <p>If you want to pay using debit, please enter your bank
account: </p>
      <% fields_for :user_account, @user_account do |fields| %>
        <p>
          <label for="user_account_bank"> credit institution:</label>
          <%= fields.text_field :bank, :size => 40 %>
        </p>
        <p>
          <label for="user_account_bank_code">bank code:</label>
          <%= fields.text_field :bank_code, :size => 40 %>
        </p>
        <p>
          <label for="user_account_account_number">account number:</

          <%= fields.text_field :account_number, :size => 40 %>
        </p>
      <% end %>

      <%= submit_tag "Register", :class => "submit" %>

    <% end %>

  </fieldset>

</div>

The user model:

class User < ActiveRecord::Base

  has_one :user_adress, :dependent => true
  has_one :user_account, :dependent => true

  validates_associated :user_account, :user_adress
  ...
end

The account model:

class UserAccount < ActiveRecord::Base
  belongs_to :user

  validates_presence_of :bank, :bank_code, :account_number

  validates_numericality_of ...
  validates_inclusion_of ...
  validates_format_of ...
end

Questions:

Validation of user_account and user_adress looks like "User adress is
invalid". I would like to show the errors for the children classes
explicitly.

How can I change "validate_presence_of" in UserAccount so that either
all or no fields are entered?

Thanks,
Luma