Closed noff closed 1 year ago
Thanks for reporting with a sample app, that's always helpful.
The resource
you're passing to respond_with_navigational
has no errors
(i.e. errors.empty?
is true
), so it will try to redirect, causing the undefined method 'users_url'
.
You need to either add some error to the object, or get rid of respond_with_navigational
altogether (you probably don't need it I imagine), and just re-render with something like render :new, status: :unprocessable_entity
so that Turbo knows to re-render the body content in place correctly.
TL;DR: replace
respond_with_navigational(resource) do
render :new
end
with
render :new, status: :unprocessable_entity
and the error should go away.
Environment
Current behavior
Here is a demo project to test: https://github.com/noff/devise_rails7_captcha_fail_demo
I try to inject captcha check on sign up for Rails7 with hotwire + Devise.
I used this manual as a start point: https://github.com/heartcombo/devise/wiki/How-To:-Use-Recaptcha-with-Devise
I generated
users/registrations
controller andusers/registrations/new
view.Added custom
create
method toUsers::RegistrationsController
:When I submit the form, I get this error:
Expected behavior
If captcha validation is failed, the sign-up form should be displayed with model's validation messages instead of 500 error.