Integration of Google reCaptcha with Rails application by Jay October 10, 2012 < 1 Minute ReadReCaptcha is a powerful captcha service to be use with a form to stop spam. This blog demonstrates the use of reCaptcha in rails application. Here I have used the ruby version 1.9.3 and Rails version 3.2.8. Environment Ruby version – 1.9.3 Rails – 3.2.8 Step#1 Create an account with Recaptcha “http://www.google.com/recaptcha” and register your site name with your google account to retrieve the public and private key that will be used later on the application Step#2 Installation of Recaptcha Gem Open your Gemfile and add this code gem 'recaptcha', :require => 'recaptcha/rails' Plugin rails plugin install git://github.com/ambethia/recaptcha.git Step#3 Create a file named recaptcha.rb in RAILS_ROOT/config/initializer and fill it with these codes ENV['RECAPTCHA_PUBLIC_KEY'] = 'youractualpublickey' ENV['RECAPTCHA_PRIVATE_KEY'] = 'youractualprivatekey' Step#4 Usages Open your views file and add this code <%= recaptcha_tags %> Step#5 Validation In controller, you can check the captcha validation by the following if @model.save && verify_recaptcha(:model => @developer, :message => "Oh! It's error with reCAPTCHA!") #captcha is valid else #captcha is invalid end SummaryArticle NameIntegration of Google reCaptcha with Rails applicationDescriptionReCaptcha is a powerful captcha service to be use with a form to stop spam. This blog demonstrates the use of reCaptcha in rails application. Here I have used the ruby version 1.9.3 and Rails version 3.2.8.Author Jay Publisher Name Andolasoft Publisher Logo Related Posts: How to Upload a File in Rails using CarrierWave Ruby on Rails Integration Testing with Minitest and Capybara Rails 5 – Most Effective Features for Apps Upgradation Tags: Rails, Rails App, Ruby Application, Ruby on Rails Jayadev Das jayadev.das@andolasoft.com Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘bout Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!