James B. wrote in post #972930:
Marnen Laibow-Koser wrote in post #972921:
James B. wrote in post #972918:
Then does that mean one must always provide a route for the new method,
even if it makes no sense to do so within a given context?
I don’t understand your question.
I get this error when I submit the form.
no route exists for “/users/1/roles”
Do you have a route defined with method PUT?
However, I get to the form via “/users/1/roles/new” called from
“/users/1/role”,
What do you mean by that? The previous page is irrelevant – HTTP is
stateless, remember?
So…describe exactly how you get here
which is where I want to return to after the update
completes.
Which page is where you want to return to?
What does the controller action look like?
At the moment I am perplexed by this, to me, mysterious
behaviour and error message.
In other words, I can start by entering
http://localhost:3000/users/1/roles
That URL displays all the roles associated with User.find(1)
Right. Standard RESTful nested resources (on GET).
From that page I follow a link to
http://localhost:3000/users/1/roles/new
which displays the input form. When I complete and submit the form I
get this error:
No route matches “/users/1/roles”
which is the very URL I have just come from.
But you came from it as GET, not PUT. Routes include method, not just
URL.
What’s your rake routes output like for these paths?
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]