zefflyn
Registered. User.
Howdy all,
Anyone have tips or code snippets, or even the proper search terms, for how to code up in rails creating a dependent record, with the id of the parent?
For instance, two models: Parents, Children.
When looking at a Parent, I want to have a link to create a new Child, that is assigned to that Parent.
Only way I know how currently is to do new.Child, and in the form, have a field allowing choice of Parents.
Everything I've tried to link from a Parent record to a new Child record has failed:
<% link_to 'Add a kid', new_child_url(@parent.id) %>
And even though I've used @parent.id earlier in the form and printed the value, it fails saying "nil value", or complains that 'new_child_url' isn't a valid method.
Gah!
Anyone have tips or code snippets, or even the proper search terms, for how to code up in rails creating a dependent record, with the id of the parent?
For instance, two models: Parents, Children.
When looking at a Parent, I want to have a link to create a new Child, that is assigned to that Parent.
Only way I know how currently is to do new.Child, and in the form, have a field allowing choice of Parents.
Everything I've tried to link from a Parent record to a new Child record has failed:
<% link_to 'Add a kid', new_child_url(@parent.id) %>
And even though I've used @parent.id earlier in the form and printed the value, it fails saying "nil value", or complains that 'new_child_url' isn't a valid method.
Gah!