Never mind, I''ve got it :)
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
On 30 Gru, 13:53, Adam
<anlauf.a...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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 }%>
> <fieldset class="alt" id="submit">
> <%= submit_tag "rejestruj"%>
> </fieldset>
> <%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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---