simple? show a child record in a form?

HI folks,

I'm new at this - but google isn't helping me find what I'm doing
wrong. Help appreciated!

I have a ship model, a ship has_one order

when editing the ship, I want to also change the order. I can't show
the existing order in the form.

I have tested that <%= @ship.order.ypos %> displays the correct value
in my form, so the data is making it's way down to the view.

I have tried variations around

<% form_tag :action => 'update', :id => @ship do %>

<p><label for="ship_name">Name</label><%= text_field 'ship', 'name'
%></p>

<p><label for="ship_order_ypos">Ypos</label><%= text_field
'ship_order', 'ypos' %></p>

<%= submit_tag 'Update' %>

<% end %>

how am I meant to do this?

thanks in advance,

Rob

Perhaps you can do this:

<% form_tag :action => 'update', :id => @ship do %>

<p><label for="ship_name">Name</label><%= text_field 'ship', 'name'
%></p>

<% fields_for "ship[order]", @ship.order do |f| %>

<p><label for="ship_order_ypos">Ypos</label><%= f.text_field
'ypos' %></p>

<% end %>

<%= submit_tag 'Update' %>

<% end %>

Which should let give you params like ship => {:name => "blah", :order
=> {:ypos => "blah"}}.

I didn't test, but that should move you in the correct direction.

Daniel

Confused Vorlon wrote: