Less Reverse Captcha

Written by on Oct 8 2008

We just released a new open source plugin for rails called Less Reverse Captcha. This is another way of doing captchas. This reverse captcha plugin does not require the user to do anything. Instead it has a hidden form field that won’t be filled out by people (because it’s hidden) but will be filled out by bots. If the field has a value the model won’t validate. That’s it, easy peasy. This plugin is similar to Erik Peterson’s negative captcha The big differences being that the Less plugin acts at the model layer, not the controller and so only needs two lines of code to make work, one for the helper method and one in the model. This plugin is already in use in Lovd By Less and now can be used in your app too!

The default error messages is configurable and obscure: “You can not create this because you are the sux.”

It’s easy to use:

new.html.erb

<= flash[:notice] %> <%= errormessagesfor :comment %>

<% form_for @comment do |form| %>

<%= form.textarea :comment %> <%= lessreversecaptchafield :comment %>

<%= submit_tag %> <% end %>

 

comments_controller.rb

def create @comment = Comment.create params[:comment] if @comment.newrecord? render :action=>‘index’ else redirectto comments_path end end

 

comment.rb

class Comment < ActiveRecord::Base

validateslessreverse_captcha

That’s it!

Meet
Steven

Hi I'm Steven,

I wrote the article you're reading... I lead the developers, write music, used to race motorcycles, and help clients find the right features to build on their product.

Get Blog Updates