# Simple? show a child record in a form?

**URL:** <https://www.ruby-forum.com/t/simple-show-a-child-record-in-a-form/126934>\
**Category:** Rails\
**Created:** [January 23, 2008, 3:57pm UTC](https://www.ruby-forum.com/t/simple-show-a-child-record-in-a-form/126934 "2008-01-23T15:57:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Confused\_Vorlon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@Confused\_Vorlon](https://www.ruby-forum.com/u/Confused_Vorlon)\
**Post date:** [January 23, 2008, 3:57pm UTC](https://www.ruby-forum.com/t/simple-show-a-child-record-in-a-form/126934/1 "2008-01-23T15:57:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Confused\_Vorlon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@Confused\_Vorlon](https://www.ruby-forum.com/u/Confused_Vorlon)\
**Post date:** [January 23, 2008, 4:38pm UTC](https://www.ruby-forum.com/t/simple-show-a-child-record-in-a-form/126934/2 "2008-01-23T16:38:09Z")

</div>

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
