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 %>

Name<%= text_field 'ship', 'name' %>

Ypos<%= text_field 'ship_order', 'ypos' %>

<%= 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 %>

Name<%= text_field 'ship', 'name' %>

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

Ypos<%= f.text_field 'ypos' %>

<% 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