Module: Gotcha::FormHelpers
- Defined in:
- lib/gotcha/form_helpers.rb
Instance Method Summary collapse
-
#gotcha(options = {}) ⇒ Object
Propose a gotcha to the user - question and answer hash.
-
#gotcha_error ⇒ Object
Return the gotcha error if its needed.
Instance Method Details
#gotcha(options = {}) ⇒ Object
Propose a gotcha to the user - question and answer hash
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gotcha/form_helpers.rb', line 6 def gotcha( = {}) [:label_options] ||= {} [:text_field_options] ||= {} if gotcha = Gotcha.random field = "gotcha_response[#{gotcha.class.name.to_s}-#{Digest::MD5.hexdigest(gotcha.class.down_transform(gotcha.answer))}]" (label_tag field, gotcha.question, [:label_options]) + "\n" + (text_field_tag field, nil, [:text_field_options]) else raise "No Gotchas Installed" end end |
#gotcha_error ⇒ Object
Return the gotcha error if its needed
18 19 20 |
# File 'lib/gotcha/form_helpers.rb', line 18 def gotcha_error t(:gotcha_validation_failed, :default => 'Failed to validate the Gotcha.') if @_gotcha_validated === false end |