I have a Post and Comment models. Comment belongs to a Post, and it is nested under Post in routes. Comments are posted from Posts#show. My routes look like this:
resources :posts do
resources :comments, only: [:create, :edit, :update, :destroy]
end
If a user submits a comment that fails validation, the URL will look like this:
app.com/posts/:id/comments
If, for any reason, the user decides to hit enter in the address bar, there will be a routing error:
Routing Error
No route matches [GET] "/posts/21/comments"
Try running rake routes for more information on available routes.
This strikes me as some what odd. I understand why the error is happening, but it doesn't seem like it's a good idea for usability. Is there a way to prevent this from happening?
This becomes a bigger issue when doing friendly redirects. When a friendly redirect happens, Rails will redirect to that same URL using a GET request, again causing a routing error.