Module: SimpleCaptcha::ControllerHelpers
- Includes:
- ConfigTasks
- Defined in:
- lib/simple_captcha_action_controller.rb
Overview
:nodoc
Instance Method Summary collapse
-
#simple_captcha_valid? ⇒ Boolean
This method is to validate the simple captcha in controller.
Instance Method Details
#simple_captcha_valid? ⇒ Boolean
This method is to validate the simple captcha in controller. It means when the captcha is controller based i.e. :object has not been passed to the method show_simple_captcha.
Example
If you want to save an object say @user only if the captcha is validated then do like this in action…
if simple_captcha_valid?
@user.save
else
flash[:notice] = "captcha did not match"
redirect_to :action => "myaction"
end
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/simple_captcha_action_controller.rb', line 21 def simple_captcha_valid? return true if RAILS_ENV == 'test' if params[:captcha] data = simple_captcha_value result = data == params[:captcha].delete(" ").upcase simple_captcha_passed! if result return result else return false end end |