Automatically filling values in a form

I have 2 models: parent & child

parent has_many children and child belongs_to parent

When a parent is created, the user has the chance to click on parent
and add a new child. I want to automatically pass back the parent_id
back to the controller, without making it part of the form.

How can this be accomplished?

The tables look like this:
parent:
id
name

child:
id
name
parent_id <-- this needs to be automatically filled based off the
selected parent.

I can get as far as verifying that I have the correct parent instance
in create child controller, but I just can’t get the parent_id to be
passed into the controller…

When a parent is created, the user has the chance to click on parent
and add a new child. I want to automatically pass back the parent_id
back to the controller, without making it part of the form.

Why don’t you want to make it part of the form?
Can’t see a reason, to make it a hidden_field like:

<%= f.hidden_field(parent_id) %>

or something the like.

Otherwise pass it with the url:

<% form_for(@child, :url => child_path(:parent_id =>
@my_parent_if_from_controller_or_whatever)) do |f| %>