Now I am trying to edit a user. What the url shows now is
http://localhost:3000/users/1/edit
But my problem is , when I click on update button and if
validations fail I am re rendering the edit page. And it happens
properly. But the url becomes
Your error case rendered the edit template... pretty standard.
The path was called on a POST (the update). There is no corresponding
GET version of that path. So when you try to go there in the browser
you get an error.
It is happening so because, when u clicked update, the browser had
sent post request to the new url which is http://localhost:3000/users/1
which is nothing but update action in ur controller. In ur update
action you are rendering the edit action if the validation failed.
Which means that url on browser doesn't change but the page being
viewed is still edit page. So when user clicks on the url and press
enter, it sends get request (not post request) to http://localhost:3000/users/1,
which actually invokes show action in your controller.
The browser behavior is actually normal and correct. If the user
clicks on the url and press enter, it should be assume that user wants
to see the data not edit.
So you actually need to define show action or redirect the user back
to edit page when validation fails (but redirecting will not carry
your validation error messages, so you may have to put some additional
efforts to carry those validation error messages).