Module: RuCaptcha::ViewHelpers

Defined in:
lib/rucaptcha/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#rucaptcha_image_tag(opts = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/rucaptcha/view_helpers.rb', line 14

def rucaptcha_image_tag(opts = {})
  @rucaptcha_image_tag__image_path_in_this_request ||= "#{ru_captcha.root_path}?t=#{Time.now.strftime('%s%L')}"
  opts[:class] = opts[:class] || "rucaptcha-image"
  opts[:src] = @rucaptcha_image_tag__image_path_in_this_request
  opts[:onclick] = "this.src = '#{ru_captcha.root_path}?t=' + Date.now();"
  tag(:img, opts)
end

#rucaptcha_input_tag(opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/rucaptcha/view_helpers.rb', line 3

def rucaptcha_input_tag(opts = {})
  opts[:name] = "_rucaptcha"
  opts[:type] = "text"
  opts[:autocorrect] = "off"
  opts[:autocapitalize] = "off"
  opts[:pattern] = "[a-zA-Z0-9]*"
  opts[:autocomplete] = "off"
  opts[:maxlength] = RuCaptcha.config.length
  tag(:input, opts)
end