Accept OpenID comments without reCAPTCHA on Enki
If you are running (or planning to do it) your Rails blog on Enki (as I do), you might want to add reCAPTCHA to avoid that some of your commenters spam your home place.
But we need to take this configuration one step further. If a visitor of yours identifies him/herself with OpenID, which is already a little hassle for him/her (you will make him pay an extra visit to his/her OpenID provider to ask for his/her credentials), you don’t want to make it even more complicated by forcing him to fill the reCAPTCHA field as well. So, how do we deactivate the spam captcha in this case?
Go to your comments_controller.rb and, at what should be the line 54 (check this out), you’ll see:
1 |
if session[:pending_comment].nil? && @comment.save |
Now, put this there instead:
1 2 3 4 5 6 7 |
if session[:pending_comment].nil? && ( verify_recaptcha( :model => @comment, :message => "Please write the words in the image in the spam captcha" ) || ( @comment.requires_openid_authentication? && @comment.openid_error.empty?) ) && @comment.save |
and you are done. Of course, you might want to replace that error message by a more suitable one.
That was an easy one to improve, right?
![Validate my Atom 1.0 feed [Valid Atom 1.0]](/images/valid-atom.png)