jdutil/contact_us — Issue #8: Adding captcha control 
Author: eddielopezzzz
Created: 2011-12-17 05:55:14+00:00
State: open

I installed the recaptcha gem in my Gemfile like so:

gem "recaptcha", :require => "recaptcha/rails"

I added the recaptcha tag in app/views/contact_us/contacts/new.html right before the submit tag

<%= recaptcha_tags :ajax => true %>

<%= f.submit t('submit'), :id => "contact_us_contact_submit" %>

The captcha control renders successfully but I am stuck as to validate the captcha control. According to http://blog.ncodedevlabs.com/2010/01/26/implementing-recaptcha-in-your-rails-app/

To verify the captcha simple add verify_recaptcha() to your controller like the below:

if verify_recaptcha(:message => "Please enter the characters. Thank you") and @user.save
redirect_to :action => “login”
flash[:notice] = “Your account setup is almost complete please check your mail for activation link.”
end

However, this contact_us script doesnt create controllers where I can add the verify_captcha() function. Any ideas as to how captcha can be implemented?