Module: SmartCapcha::Controller
- Defined in:
- lib/smart_capcha.rb
Class Method Summary collapse
Instance Method Summary collapse
- #captcha_failure ⇒ Object
- #captcha_passed? ⇒ Boolean
- #prepare_capcha_question ⇒ Object
- #valid_smart_capcha? ⇒ Boolean
Class Method Details
.included(obj) ⇒ Object
7 8 9 10 |
# File 'lib/smart_capcha.rb', line 7 def self.included(obj) obj.helper_method :captcha_passed?, :prepare_capcha_question obj.helper SmartCapcha::Helper end |
Instance Method Details
#captcha_failure ⇒ Object
27 28 29 30 |
# File 'lib/smart_capcha.rb', line 27 def captcha_failure flash[:capcha_error] = Questionnaire.config[:failure_message] false end |
#captcha_passed? ⇒ Boolean
23 24 25 |
# File 'lib/smart_capcha.rb', line 23 def captcha_passed? session[:captcha_status] == encrypt(params[:captcha_answer]) end |
#prepare_capcha_question ⇒ Object
17 18 19 20 21 |
# File 'lib/smart_capcha.rb', line 17 def prepare_capcha_question result = Questionnaire.find_random_question session[:captcha_status] = encrypt(result.last) result.first end |
#valid_smart_capcha? ⇒ Boolean
12 13 14 15 |
# File 'lib/smart_capcha.rb', line 12 def valid_smart_capcha? return captcha_failure unless params[:captcha_answer] captcha_passed? ? true : captcha_failure end |