Skip to content

Commit

Permalink
Add status: :unprocessable_entity to all failed render responses
Browse files Browse the repository at this point in the history
This will help keep things consistent with Rails 7 and Turbo.

Issues
------
- Closes #52
  • Loading branch information
stevepolitodesign committed Jan 7, 2022
1 parent 6a8f23e commit 5b713f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -755,11 +755,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

Expand Down Expand Up @@ -1334,7 +1334,7 @@ class SessionsController < ApplicationController
end
else
flash.now[:alert] = "Incorrect email or password."
render :new
render :new, status: :unprocessable_entity
end
end
...
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create
end
else
flash.now[:alert] = "Incorrect email or password."
render :new
render :new, status: :unprocessable_entity
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5b713f8

Please sign in to comment.