Reusing trhe same form as partial for add and update

HI!
I have a form which I want to reuse for adding and updating a user.
The thing is I have 3 models in it
user, address, phone

in the manage view I have

<% if params[:id].blank? -%>
<%form_for :user, :url=>{:action=>:register} do |form| %>
<%= render :partial=>‘form’, :locals => { :form => form }%>

<%= submit_tag "rejestruj"%> <%end%> <%else -%> <%form_for :user,@user, :url=>{:action=>:update,:id=>@user.id} do | form| %> <%= render :partial=>'form', :locals => { :form => form }%> <% end %> <%end%>

so I’m adding the @user object. Is there a way to check inside the
partial form if the user != nil
and then do
<% fields_for :address, @user.address do |a|%>
or
<% fields_for :address do |a|%>

I’ve tried it with if, ? : and so on but without any luck.

Never mind, I’ve got it :slight_smile:

Just made antoher partial for the address and the same way as the main
form with
<% if @user %>
<% fields_for :address, @user.address do |a|%>
<%= render :partial=>‘address’,:locals=>{:a => a} %>
<%end%>
<%else %>
<% fields_for :address do |a|%>
<%= render :partial=>‘address’,:locals=>{:a => a} %>
<%end%>
<%end%>

Sorry for such quick question