In Rails when a resource create action fails and calls render :new, why must the URL change to the resource’s index url?

It actually is sending you to the create path. It’s in the create action, the path for which is /books, using HTTP method POST. This looks the same as the index path /books, but the index path is using HTTP method GET. The rails routing code takes the method into account when determining which action to call. After validation fails, you’re still in the create action, but you’re rendering the new view. It’s a bit confusing, but a line like render :new doesn’t actually invoke the new action at all; it’s still running the create action and it tells Rails to render the new view.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)