Module: EasyCaptcha::ModelHelpers::InstanceMethods

Defined in:
lib/easy_captcha/model_helpers.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#captcha_valid?Boolean Also known as: valid_captcha?

validate captcha

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/easy_captcha/model_helpers.rb', line 20

def captcha_valid?
  return true if captcha.present? && captcha_verification.present? && captcha_verification_match?
  errors.add(:captcha, :invalid)
  false
end

#captcha_verification_match?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/easy_captcha/model_helpers.rb', line 27

def captcha_verification_match?
  captcha.to_s.casecmp(captcha_verification.to_s).zero?
end