Module: ReallySimpleCaptcha::Captcha::PlainCaptcha::ViewHelpers

Defined in:
lib/really_simple_captcha/captcha/plain_captcha.rb

Instance Method Summary collapse

Instance Method Details

#plain_captcha_tagObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/really_simple_captcha/captcha/plain_captcha.rb', line 39

def plain_captcha_tag
  session[PlainCaptcha.field_name] = ReallySimpleCaptcha::Util.random_string(PlainCaptcha.text_length)

  image = PlainCaptcha.generate_image(session[:plain_captcha],
                                      PlainCaptcha.config.select { |k,v| DEFAULT_OPTIONS.has_key?(k) })

   :div, class: 'plain_captcha' do
    html = image_tag "data:image/gif;base64,#{image}", alt: "Captcha"
    html.concat text_field_tag PlainCaptcha.field_name, nil, required: 'required', autocomplete: 'off'

    html
  end
end