Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to use hCaptcha with Ruby on Rails, Turbo, and Stimulus.js Discussion

Thanks for posting this.

Reply

On the save_with_captcha function you are running the "valid?" in the Hcaptcha.success if-else statement meaning if Hcaptcha.success fails on the else statement - run "valid?" , and if Hcaptcha.success is successful you are calling "save" method. Shouldn't the "valid?" run regardless if Hcaptcha is successful or not? Because Hcaptcha.success might be successful but other validations might fail.

Reply

save will run the validations before it persists, so there is no need to call valid? if you are calling save. The call to valid? in the else block is just to populate the errors on the object so your form can show them.

Reply

I consider invisible_captcha gem an easiest way to avoid bots. No extra steps for real users, only for the bots

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,969+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.