Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

recaptcha plugin for rails

I am currently using ambethia's recaptcha plugin for rails. I want to disable the message

"incorrect-captcha-sol"

whenever the user incorrectly enters the wrong recaptcha. How should I go about doing this?

In the source file I get the following tags surrounding the error message

<p class="recaptcha_error">incorrect-captcha-sol</p>
like image 901
denniss Avatar asked Dec 10 '22 14:12

denniss


2 Answers

Because flash[] is an array you could delete element inside it. When we use recaptcha gem, the flash array contain recaptcha_error element, so you just only delete this element with : flash.delete(:recaptcha_error) inside your controller.

For example :

if  verify_recaptcha(:model=>@object,:message=>"Verification code is wrong", :attribute=>"verification code") && @object.save
  #your code if succes
else
  flash.delete(:recaptcha_error)
  #your code if its fail
end

Maybe it could help you. Thanks

like image 96
Agung Prasetyo Avatar answered Dec 29 '22 17:12

Agung Prasetyo


The plugin sets the flash (more precisely flash[:recaptcha_error]), i.e. it won't display message automatically. Most likely you have a piece of code that displays all flash messages. Try removing it and/or excluding flash[:recaptcha_error] from being displayed.

like image 45
Slobodan Kovacevic Avatar answered Dec 29 '22 17:12

Slobodan Kovacevic