# reCAPTCHA headache

**URL:** <https://www.ruby-forum.com/t/recaptcha-headache/183092>\
**Category:** Rails\
**Created:** [February 8, 2010, 1:48am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092 "2010-02-08T01:48:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 8, 2010, 1:48am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/1 "2010-02-08T01:48:31Z")

</div>

I’m trying to use this ([http://ambethia.com/recaptcha/](http://ambethia.com/recaptcha/)) reCAPTCHA  
plugin and have almost got it working. Help me get the last part? I  
can’t seem to find anything in the logs that indicate an error.

Here is my code. Everything is working good except that part where the  
code that’s typed is actually validated. Instead, it keeps kicking  
back an error. Everything appears to be installed correctly, since the  
reCAPTCHA box is showing up; it’s just not letting my form save even  
though the words are typed correctly.

new.html.erb:  
…  
\<%= recaptcha\_tags %\>  
  
  
\<%= f.submit ‘Submit Your Job’ %\>  
\<% end %\>

jobs\_controller.rb:  
def create  
@job = Job.new(params[:job])

```
respond_to do |format|
    if verify_recaptcha
  @job.save
    flash[:notice] = 'You job listing was successfully created.'
    format.html { redirect_to(@job) }
    format.xml { render :xml => @job, :status

```

=\> :created, :location =\> @job }  
else  
flash[:notice] = ‘There was an error with the reCAPTCHA,  
please  
try again.’  
format.html { render :action =\> “new” }  
format.xml { render :xml =\> @job.errors, :status  
=\> :unprocessable\_entity }  
end  
end  
end

Thanx in advance,

Eric

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 8, 2010, 5:08am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/2 "2010-02-08T05:08:17Z")

</div>

Is it throwing some kind of rails error or is the reCAPTCHA not  
accepting a correct answer?

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 8, 2010, 5:26am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/3 "2010-02-08T05:26:27Z")

</div>

You may want to try this one as an alternative:

[http://expressica.com/simple\_captcha/](http://expressica.com/simple_captcha/)

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 8, 2010, 5:28am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/4 "2010-02-08T05:28:01Z")

</div>

Hi Sean, thanks for writing.

The only error I get is that the words typed were incorrect and that I  
need to try again. But the words are correct; it’s not accepting the  
words that are typed.

Eric

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 8, 2010, 5:38am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/5 "2010-02-08T05:38:33Z")

</div>

That doesn’t look bad, but I’d love to find something that doesn’t use  
RMagick.

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 8, 2010, 6:17am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/6 "2010-02-08T06:17:47Z")

</div>

It must be something related to your installation of the plugin. It is  
hard to say with the available information you provided what is going  
on. Have you properly installed the keys? Here is an application that  
uses recaptcha. You can use it as a reference I suppose.

[http://www.opensourcerails.com/projects/282124-Rails-Dev-Directory](http://www.opensourcerails.com/projects/282124-Rails-Dev-Directory)

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 9, 2010, 2:52pm UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/7 "2010-02-09T14:52:52Z")

</div>

Upon closer inspection, it was discovered that reCAPTCHA information  
was not being submitted with the form. Form elements were aligned in  
a table (I know, I know…but it usually works so well…). Removing  
the table caused reCAPTCHA information to be submitted with the rest  
of the form. There must be a reference that the iframe couldn’t make  
when it was wrapped in its own

 tags.

-Kyle

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 9, 2010, 1:02am UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/8 "2010-02-09T01:02:15Z")

</div>

Eric,

I have it going using the validation syntax recommended in the RDoc:

if verify\_recaptcha(:model =\> @job) && @job.save  
…

When I tried using an if/else for the validation, a mismatch threw an  
error.

-Kyle

---

<div class="post-metadata">

**Author:** ![Eric\_J\_Gruber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d2c977/32.png) [@Eric\_J\_Gruber](https://www.ruby-forum.com/u/Eric_J_Gruber)\
**Post date:** [February 9, 2010, 2:57pm UTC](https://www.ruby-forum.com/t/recaptcha-headache/183092/9 "2010-02-09T14:57:40Z")

</div>

Kyle wrote:

> Upon closer inspection, it was discovered that reCAPTCHA information  
> was not being submitted with the form. Form elements were aligned in  
> a table (I know, I know…but it usually works so well…).

And now the lecture: don’t use tables for alignment under any  
circumstances. They are _only_ for tabular data. Break this rule at  
your peril. Instead of being apologetic, just _don’t do_ things you  
want to apologize for.

> Removing  
> the table caused reCAPTCHA information to be submitted with the rest  
> of the form. There must be a reference that the iframe couldn’t make  
> when it was wrapped in its own tags.
> 
> -Kyle

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
