Module: Rack::Captchachacha::Helpers

Defined in:
lib/rack/captchachacha/helpers.rb

Instance Method Summary collapse

Instance Method Details

#captcha_answer_tagObject



22
23
24
# File 'lib/rack/captchachacha/helpers.rb', line 22

def captcha_answer_tag
  %Q!<input id="captcha_answer" name="captcha_answer" type="text" size="6"/>!
end

#captcha_image_tagObject



27
28
29
# File 'lib/rack/captchachacha/helpers.rb', line 27

def captcha_image_tag
  %Q!<input id="captcha_session" name="captcha_session" type="hidden" value="#{captcha_session}"/><img id="captcha_image" src="http://captchator.com/captcha/image/#{captcha_session}"/>!
end

#captcha_sessionObject



17
18
19
# File 'lib/rack/captchachacha/helpers.rb', line 17

def captcha_session
  @captcha_session ||= SecureRandom.random_number.to_s[2..-1]
end

#captcha_valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rack/captchachacha/helpers.rb', line 12

def captcha_valid?
  request.env['X-Captcha-Valid']
end