Module: ActsAsTextcaptcha::TextcaptchaHelper

Defined in:
lib/acts_as_textcaptcha/textcaptcha_helper.rb

Instance Method Summary collapse

Instance Method Details

#textcaptcha_fields(f, &block) ⇒ Object

builds html fields for spam question, answer and hidden encrypted spam answers



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/acts_as_textcaptcha/textcaptcha_helper.rb', line 5

def textcaptcha_fields(f, &block)
  model        = f.object
  captcha_html = ''
  if model.perform_textcaptcha?
     captcha_html += f.hidden_field(:spam_answers)
     if model.spam_answer
       captcha_html += f.hidden_field(:spam_answer)
     elsif model.spam_question
       captcha_html += capture(&block)
     end
  end

  # Rails 2 compatability
  if Rails::VERSION::MAJOR < 3
    concat captcha_html, &block.binding
  else
    captcha_html.html_safe
  end
end