Guillaume Dott 04e016c188 Use Time.now.nsec for text field id
The text field id has to be unique for when you want two different
captchas on the same page.
2015-10-19 10:35:21 +02:00

25 lines
608 B
Ruby

module ReallySimpleCaptcha::Captcha
module ReverseCaptcha
include ActiveSupport::Configurable
config_accessor :field_name
config.field_name = :reverse_captcha
def self.configure(&block)
yield config
end
module ViewHelpers
def reverse_captcha_tag
content_tag :div, text_field_tag(ReverseCaptcha.field_name, nil, id: "reverse_captcha_#{Time.now.nsec}"), class: 'reverse_captcha', style: 'display: none'
end
end
module ControllerHelpers
def reverse_captcha_valid?
params[ReverseCaptcha.field_name].blank?
end
end
end
end