Rails devise with recaptcha

I'm trying to use the recaptcha gem with devise 2.0.0 in rails 3.2.1.

Every time I try, I am able to display the captcha and input the 2
words it asks about. But in my controller (using code I found on
github for the recaptcha gem, and after I replaced render_with_context
with just plain render) verify_recaptcha always returns false and when
I look at flash[:recaptcha_error] it says "recaptcha-not-reachable".
The only thing I can see that might be a problem is that one of the
examples of configuring the config values for recaptcha showed a proxy
setting. I don't generally use a proxy so I just left that setting
out. Is there some reason why sending the captcha results to the
recaptcha server would require a proxy when getting the basic captcha
to display works just fine without one? Any other hints about what
might be wrong? Is there a better solution I should look at instead?



I did a little research inside the recaptcha gem code and discovered that "recaptcha-not-reachable" means that the code timed out before it got a response from the recaptcha website. Turns out the default timeout value is set at only 3 seconds. I was able to resolve the problem by changing the call to verify_recaptcha so that it included a higher timeout value:

if verify_recaptcha( :model => resource, :timeout => 30)

did the trick nicely.

While I think that 3 seconds is a little short for the default timeout, I was really pleased at what a simple mechanism was already in place to alter it!