I’m trying to use this (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
Is it throwing some kind of rails error or is the reCAPTCHA not
accepting a correct answer?
You may want to try this one as an alternative:
http://expressica.com/simple_captcha/
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
That doesn’t look bad, but I’d love to find something that doesn’t use
RMagick.
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
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
|
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
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
[email protected]