Module: TinyCaptcha::ViewHelper
- Defined in:
- lib/tiny_captcha/view.rb
Overview
:nodoc
Instance Method Summary collapse
-
#show_tiny_captcha(*args) ⇒ Object
Tiny Captcha is a very simplified captcha.
Instance Method Details
#show_tiny_captcha(*args) ⇒ Object
Tiny Captcha is a very simplified captcha.
It can be used as a Model or a Controller based Captcha depending on what options we are passing to the method show_tiny_captcha.
show_tiny_captcha method will return the image, the label and the text box. This method should be called from the view within your form as…
<%= show_tiny_captcha %>
The available options to pass to this method are
-
label
-
object
Label:
default label is “type the text from the image”, it can be modified by passing :label as
<%= show_tiny_captcha(:label => “new captcha label”) %>.
Object
This option is needed to create a model based captcha. If this option is not provided, the captcha will be controller based and should be checked in controller’s action just by calling the method tiny_captcha_valid?
To make a model based captcha give this option as…
<%= show_tiny_captcha(:object => “user”) %> and also call the method apply_tiny_captcha in the model this will consider “user” as the object of the model class.
Examples
-
controller based
<%= show_tiny_captcha(:label => “Human Authentication: type the text from image above”) %>
-
model based
<%= show_tiny_captcha(:object => “person”, :label => “Human Authentication: type the text from image above”) %>
Find more detailed examples with sample images here on my blog EXPRESSICA.com
All Feedbacks/CommentS/Issues/Queries are welcome.
eg. show_tiny_captcha :label => ”, :captcha_key => ”, :image_url => ”
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/tiny_captcha/view.rb', line 49 def show_tiny_captcha(*args) = args. [:captcha_key] ||= set_tiny_captcha_data( ( args.first || tiny_captcha_key([:object]) ), ) key = [:captcha_key] defaults = { :image => tiny_captcha_image(key, ), :label => [:label] || I18n.t('tiny_captcha.label'), :field => tiny_captcha_field() } render :partial => 'tiny_captcha/tiny_captcha', :locals => { :tiny_captcha_options => defaults } end |