hidden_field vs. form_for Parameter


I have a question regarding the best way to do the following:

Given I have a Parent model that has many Child models, and the "show"
page for the parent model allows the user to create a new Child, which
is preferable?

A) <% form_for(@child, :parent_id => @parent.id) do |f| %>
     f.text_field :foo
     f.text_field :bar
   <% end %>

-- OR --

B) <% form_for(@child) do |f| %>
     f.hidden_field :parent_id, :value => @parent.id
     f.text_field :foo
     f.text_field :bar
   <% end %>

AFAIK both ways accomplish the same thing, I'm just wondering if there
was a preferred "Rails" way.


If I understand you question, the first. The second puts unnecerssary
hidden field on the form and the form helper already has the I'd
embeded. Only reason you would want the hidden field is if you needed
it perhaps for ajax/js purposes.