Skip to content

Commit 9fa2756

Browse files
Add status: :unprocessable_entity to all failed render responses
This will help keep things consistent with Rails 7 and Turbo. Issues ------ - Closes #52
1 parent 97d35f2 commit 9fa2756

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class UsersController < ApplicationController
188188
if @user.save
189189
redirect_to root_path, notice: "Please check your email for confirmation instructions."
190190
else
191-
render :new
191+
render :new, status: :unprocessable_entity
192192
end
193193
end
194194

@@ -525,11 +525,11 @@ class SessionsController < ApplicationController
525525
redirect_to root_path, notice: "Signed in."
526526
else
527527
flash.now[:alert] = "Incorrect email or password."
528-
render :new
528+
render :new, status: :unprocessable_entity
529529
end
530530
else
531531
flash.now[:alert] = "Incorrect email or password."
532-
render :new
532+
render :new, status: :unprocessable_entity
533533
end
534534
end
535535

@@ -755,11 +755,11 @@ class PasswordsController < ApplicationController
755755
redirect_to login_path, notice: "Signed in."
756756
else
757757
flash.now[:alert] = @user.errors.full_messages.to_sentence
758-
render :edit
758+
render :edit, status: :unprocessable_entity
759759
end
760760
else
761761
flash.now[:alert] = "Incorrect email or password."
762-
render :new
762+
render :new, status: :unprocessable_entity
763763
end
764764
end
765765

@@ -1334,7 +1334,7 @@ class SessionsController < ApplicationController
13341334
end
13351335
else
13361336
flash.now[:alert] = "Incorrect email or password."
1337-
render :new
1337+
render :new, status: :unprocessable_entity
13381338
end
13391339
end
13401340
...

app/controllers/passwords_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def update
3939
redirect_to login_path, notice: "Password updated."
4040
else
4141
flash.now[:alert] = @user.errors.full_messages.to_sentence
42-
render :edit
42+
render :edit, status: :unprocessable_entity
4343
end
4444
else
4545
flash.now[:alert] = "Incorrect email or password."
46-
render :new
46+
render :new, status: :unprocessable_entity
4747
end
4848
end
4949

app/controllers/sessions_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def create
1515
end
1616
else
1717
flash.now[:alert] = "Incorrect email or password."
18-
render :new
18+
render :new, status: :unprocessable_entity
1919
end
2020
end
2121

app/controllers/users_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def create
88
@user.send_confirmation_email!
99
redirect_to root_path, notice: "Please check your email for confirmation instructions."
1010
else
11-
render :new
11+
render :new, status: :unprocessable_entity
1212
end
1313
end
1414

0 commit comments

Comments
 (0)