Module Ramaze::Helper::SimpleCaptcha
In: lib/ramaze/helper/simple_captcha.rb

Produce very simple question/answer pairs.

The default is a trivial mathematical problem.

Usage (trait is optional):

  class RegisterController < Ramaze::Controller
    trait :captcha => lambda{
      ["the answer to everything", "42"]
    }

    def index
      %(
        <form action="#{r(:answer}">
          What is #{simple_captcha}?
          <input type="text" name="answer" />"
          <input type="submit" />
        </form>
      ).strip
    end

    def answer
      check_captcha(request[:answer])
    end
  end

Methods

Included Modules

Ramaze::Traited

Constants

NUMBERS = [5, 10, 15, 20]

Public Instance methods

check the given answer against the answer stored in the session.

Call the trait[:captcha] and store question/answer in session

[Validate]