recaptcha
recaptcha copied to clipboard
verify_recaptcha not prevent saving in ajax form
I'm tying to add recaptcha validation in AJAX form like in a simple usage but i found this error: added verification not prevent new item from saving if captcha verification fails. Full content of create action in controller below:
def create
@question = Question.new(question_params)
respond_to do |format|
if verify_recaptcha(model: @question, message: 'Вы не прошли проверку CAPTCHA. Вы действительно человек?') && @question.save
format.js
else
format.js
end
end
end
Is there any way to fix this weird bug?
verify_recaptcha returns false when it fails ... so it should not trigger the save ... can you reproduce this in the example app so I can dig in why it happens ?
This project must work. Don't forget to add secret_key_base and recaptcha tokens. Here are 1 record in db:seed for proper working.
Instruction for testing: under the video here are link to call form. Fill all the fields but don't touch recaptcha. Form will be sent successful.
https://github.com/vadimzham/recaptcha-test
no idea how to get your repo to show a validation ... I pushed a demo example with a model verification and it works fine, please copy this example code or make it break in the demo