Friday, 23 August 2013

Nested Resources Post Issue

Nested Resources Post Issue

I have a rails 4 application that has two scaffolds (that are the same as
the default you generate). I have a routes.rb that looks like this:
resources :companies do
resources :peoples
end
Until I added the nested routes, the two scaffolds worked perfectly alone.
But when I added the nested routes, when I visit a route like:
http://localhost:3000/companies/bobs-pizza/peoples/new
and fill out the peoples form and submit, I get an error like:
Routing Error
No route matches [POST] "/companies/bobs-pizza/peoples/new"
my _form.html.erb for the peoples scaffold ( the child in the relationship
between peoples and companies) I changed to look like this:
<%= form_for companies_path(@company,@people) do |f| %>
Thanks for all help.

No comments:

Post a Comment