## user.rb

class User < ActiveRecord::Base
attr_accessible :id, :name, :zipcode

has_one :authentication, :inverse_of => :user, :dependent => :destroy
accepts_nested_attributes_for :authentication
end

## authentication.rb

class Authentication < ActiveRecord::Base
attr_accessible :id, :user_id, :email

has_one :authenticationdetail
belongs_to :user
end

## authenticationdetail.rb

class Authenticationdetail < ActiveRecord::Base
belongs_to :authentication
end

## authentications_controller.rb

class AuthenticationsController < ApplicationController
def new
@user ||= User.find(params[:user_id] if params[:user_id]
if @user
@user.build_authentication(:user_id => @user.id)
else
redirect_to root_path
flash[:notice] = "Error occured"
end
end
end

## authentication form

<%= form_for @user do |a| %>
<% @user.errors.full_messages.each do |msg| %>
<p><%= msg %></p>
<% end %>
<%= a.fields_for :authentication do |builder| %>
<div>
<p>
<%= builder.label :email %>
<%= builder.text_field :email %>
</p>
<p>
<%= builder.label :email_confirmation %>
<%= builder.text_field :email_confirmation %>
</p>
</div>
<% end %>
<p class="submit">
<%= a.submit "continue" %>
</p>
<% end %>