Module: YandexCaptcha::Helpers::Rails

Defined in:
lib/yandex_captcha/helpers/rails.rb

Instance Method Summary collapse

Instance Method Details

#captcha_tags(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/yandex_captcha/helpers/rails.rb', line 4

def captcha_tags(options = {})
  return if YandexCaptcha.skip_env

  if options[:ajax]
    render partial: "yandex_captcha/captcha_ajax"
  else
    error = options[:error] ||= ((defined? flash) ? flash[:yandex_captcha_error] : "")
    captcha = YandexCaptcha::Verify.get_captcha
    render partial: "yandex_captcha/captcha", locals: { captcha: captcha, error: error, noscript: options[:noscript] } if captcha
  end
end