reCAPTCHA on Rails [Installing Rails plugin on Windows]

1. Register at Add your domain and get two keys (one public, one private). I created two sites once registered, one for my development environment (localhost), and one for production.
2. Install recaptcha plugin for Rails. (GitHub).

$ ./script/plugin install git://
This might be PITA for the Windows users. I wasted 3-4 hrs figuring this out. The links I used are :-
Check if these links work for you since they are relatively simple and worked for some users. But I always faced the issue :-
C:\Projects\rajdhani>ruby script/plugin install
Plugin not found: []
Solution to installing Rails plugin on Windows
1. Install git for Windows : [All default options. Do not change any options]. You might want to restart your computer.
2. Start Git GUI->Clone repository->Source:git://>Destination: C:\\vendor\plugins\recaptcha [needs to be a new folder]
3. Restart the Rails server

3. Take the public and private reCAPTCHA keys and save to environment.rb or your environment file. I added the following to the bottom of my development.rb, replacing the ‘MY_PUBLIC_KEY’ and ‘MY_PRIVATE_KEY’ with the keys from (include single quotes):


4. Edit views where you want the reCAPTCHA box to appear. The plugin defines a special view helper named recaptcha_tags. Here’s a basic example:

Is a SAC project?   

    Human Test: <%= recaptcha_tags %>


And here’s what it that basic html looks like:
Each page load will embed code that pings the reCAPTCHA API and generates a new captcha. Note that there are some extra options on recaptcha_tags if you need to handle ssl or want to by default not use javascript (uses an iframe instead).
5. Add verification in the controller:

if verify_recaptcha() and
        flash[:notice] = ‘Project was successfully created.’
        format.html { redirect_to(@project) }
        format.html { render :action => “new” }

The verify_recaptcha() method will take params from the POST request, ping, and then return true or false. Then you can handle it however you want (here in the same block as model validation). If the captcha fails, it’ll render the new page again.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s