Nested resources form_for problem


I have a resource map like this:

map.resources :users do |user|
user.resource :sreg10record

So a User is supposed to have (at most) one Sreg10record. The problem
is in the views. I tried following this tutorial:

which proposes something like:

<% form_for( [@user, @sreg10record] ) do |f| %>

However, doing that yields “undefined method `has_key?’ for
#Sreg10record:0xb6f47bc4”. So I tried

<% form_for( [:user, @sreg10record] ) do |f| %>

as intended for namespaced resources, however that causes the ID of
the record to be used in the URL, which then causes the controller to
fail when retrieving @user. Experiments with url_for (which appears to
be used by form_for anyway) or user_sreg10record_url(@user) failed in
more or less entertaining ways too. So, how do I make form_for
generate a valid path like “/users/<user_id>/sreg10record”?

A small addition: when using

<% form_for( user_sreg10record_url(@user) ) %>

the generated URL is apparently right, but all form fields are left
empty. Submitting the form ends up somewhere where “Only get requests
are allowed.” In the form, there’s a happy mixture of the user’s ID
and the record’s ID.

On Dec 28, 4:52 pm, “[email protected][email protected]