0

I have a nested resource in my routes.rb file:

resources :users do
  resources :children
end

I have a form at /users/:id/children/new. Form comes up fine and the embedded ruby for the form looks like this:

<%= form_for(@user) do |f| %>

Problem is I want this to submit to /users/:id/children, but it submits to /users. Is there a standard way this should be done in Rails?

at.
  • 50,922
  • 104
  • 292
  • 461

1 Answers1

1

The embedded form shold look like this

<%= form_for [@user, Children.new] do |f|%>
 <%= f.label :children_attr,.....%>
  .
  .

see this vedio, it might help.

Alaa Othman
  • 1,109
  • 12
  • 16
  • hmm.. I don't have a `Children` model or a `Child` model. They are actually a `User` too. I just call the resource `children` because otherwise it would be `resources :users do; resources :users; end` – at. Oct 06 '14 at 05:51