From 3fbe3fdf3d7adb0a313cb06ad557b3c65827ff7d Mon Sep 17 00:00:00 2001 From: Steve Polito Date: Fri, 7 Jan 2022 05:58:43 -0500 Subject: [PATCH] Add status: :unprocessable_entity to all failed render responses This will help keep things consistent with Rails 7 and Turbo. Issues ------ - Closes #52 --- README.md | 12 ++++++------ app/controllers/passwords_controller.rb | 4 ++-- app/controllers/sessions_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2b6bc85..e5c2a87 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ class UsersController < ApplicationController if @user.save redirect_to root_path, notice: "Please check your email for confirmation instructions." else - render :new + render :new, status: :unprocessable_entity end end @@ -525,11 +525,11 @@ class SessionsController < ApplicationController redirect_to root_path, notice: "Signed in." else flash.now[:alert] = "Incorrect email or password." - render :new + render :new, status: :unprocessable_entity end else flash.now[:alert] = "Incorrect email or password." - render :new + render :new, status: :unprocessable_entity end end @@ -754,11 +754,11 @@ class PasswordsController < ApplicationController redirect_to login_path, notice: "Signed in." else flash.now[:alert] = @user.errors.full_messages.to_sentence - render :edit + render :edit, status: :unprocessable_entity end else flash.now[:alert] = "Incorrect email or password." - render :new + render :new, status: :unprocessable_entity end end @@ -1333,7 +1333,7 @@ class SessionsController < ApplicationController end else flash.now[:alert] = "Incorrect email or password." - render :new + render :new, status: :unprocessable_entity end end ... diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index d336a88..814bdce 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -39,11 +39,11 @@ def update redirect_to login_path, notice: "Password updated." else flash.now[:alert] = @user.errors.full_messages.to_sentence - render :edit + render :edit, status: :unprocessable_entity end else flash.now[:alert] = "Incorrect email or password." - render :new + render :new, status: :unprocessable_entity end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b97f9ce..4faea94 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -15,7 +15,7 @@ def create end else flash.now[:alert] = "Incorrect email or password." - render :new + render :new, status: :unprocessable_entity end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1444f34..990501c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -8,7 +8,7 @@ def create @user.send_confirmation_email! redirect_to root_path, notice: "Please check your email for confirmation instructions." else - render :new + render :new, status: :unprocessable_entity end end