Module: CustomCaptcha::ActionViewExtension::Base::InstanceMethods

Defined in:
lib/custom_captcha/action_view_extension.rb

Instance Method Summary collapse

Instance Method Details

#display_custom_captcha(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/custom_captcha/action_view_extension.rb', line 11

def display_custom_captcha(options={})
  return "" if CustomCaptcha::Configuration.disable?
  options[:key] = choice_image_file_path_and_write_session_cache

  options[:field_name] ||= CustomCaptcha::DEFAULTVALUE[:field_name]
  options[:key_name] ||= CustomCaptcha::DEFAULTVALUE[:key_name]
  options[:key_id] ||= CustomCaptcha::DEFAULTVALUE[:key_id]
  options[:img_id] ||= CustomCaptcha::DEFAULTVALUE[:img_id]

  options[:img_src] = show_captcha_image_path(options[:key])
  options[:template] ||= CustomCaptcha::DEFAULTVALUE[:template]
  options[:label_text] ||= I18n.t('custom_captcha.label')
  options[:change_text] ||= I18n.t('custom_captcha.change')
  options[:change_url] = change_captcha_images_path(:img_id => options[:img_id], :key_id => options[:key_id])
  render "custom_captcha/captcha_styles/#{options[:template].to_s}", :captcha => options
end