I started new project and am stuck for hours trying to make Sign In page show errors. Though when I try to write incorrect data on Sign up page it returns errors, Sign in completely ignores it. I found decision concerning devise for rails 7 from gorails, it didn't help.
Gemfile:
gem "devise", git: "https://github.com/ghiculescu/devise.git", branch: "error-code-422"
gem "responders", git: "https://github.com/heartcombo/responders.git"
config/initializers/devise.rb:
Devise.setup do |config|
...
config.navigational_formats = ['*/*', :html, :turbo_stream]
...
Did it in order not to add new controller and custom error as it was shown in video. Also, console returns 422, but in terminal still:
Started POST "/users/sign_in" for ::1 at 2022-11-29 12:46:57 +0200
Processing by Devise::SessionsController#create as HTML
Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["email", "[email protected]"], ["LIMIT", 1]]
Completed 401 Unauthorized in 271ms (ActiveRecord: 0.3ms | Allocations: 1727)
Processing by Devise::SessionsController#new as HTML
Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
Rendering layout layouts/application.html.haml
Rendering devise/sessions/new.html.haml within layouts/application
Rendered devise/shared/_error_messages.html.haml (Duration: 0.0ms | Allocations: 12)
Rendered devise/shared/_links.html.haml (Duration: 0.2ms | Allocations: 137)
Rendered devise/sessions/new.html.haml within layouts/application (Duration: 3.5ms | Allocations: 1348)
Rendered layout layouts/application.html.haml (Duration: 5.4ms | Allocations: 2506)
Completed 200 OK in 251ms (Views: 6.3ms | ActiveRecord: 0.0ms | Allocations: 3124)
My views are default generated by devise. If I should provide more info, like application.html.haml etc, please tell me.
Edit: Devise 4.9.0 has been released, which fixes this issue. Upgrade Devise and modify your Devise config to match the block below. Configs generated after 4.9.0 will have the correct values.
From: https://github.com/heartcombo/devise/blob/v4.9.0/CHANGELOG.md:
Original answer / workaround (no longer needed):
This is a known issue with Devise, and for now the recommended fix is to disable Turbo on Devise's log in/out forms.
From https://github.com/heartcombo/devise/wiki/Troubleshooting-Rails-7-and-Turbo-Drive :
One trick you can use for Devise's log out link, since it uses the HTTP DELETE method, is to change it to a button, like so:
... but the wiki link above has other samples as well.
There are some more details and discussions here: