Module: CaptchaHelper

Defined in:
lib/captcha3/captcha_helper.rb

Instance Method Summary collapse

Instance Method Details

#captcha_block(label = '请输入验证码') ⇒ Object



16
17
18
# File 'lib/captcha3/captcha_helper.rb', line 16

def captcha_block(label='请输入验证码')
	("div", captcha_hidden_text + captcha_input_text(label) + captcha_image, {:class => 'captcha'})
end

#captcha_hidden_textObject



11
12
13
14
# File 'lib/captcha3/captcha_helper.rb', line 11

def captcha_hidden_text
	@captcha_image ||= CaptchaUtil.random_image
	hidden_field_tag(:captcha_validation, @captcha_image.gsub(/\..+$/, ''))
end

#captcha_image(options = {}) ⇒ Object



2
3
4
5
# File 'lib/captcha3/captcha_helper.rb', line 2

def captcha_image(options = {})
	@captcha_image ||= CaptchaUtil.random_image
	image_tag("/system/captcha3/" + @captcha_image, options)
end

#captcha_input_text(label, options = {}) ⇒ Object



7
8
9
# File 'lib/captcha3/captcha_helper.rb', line 7

def captcha_input_text(label, options = {})
	('label', label, :for => 'captcha') + text_field_tag(:captcha, nil, options) 	
end