From c310c25781e8f58cfada22901f2b1b3e89a10657 Mon Sep 17 00:00:00 2001 From: kamionayuki Date: Tue, 27 Oct 2015 21:22:21 +0800 Subject: [PATCH] Update controller_helpers.rb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在ruby2.2.0p0版本中,&& 与 and 的优先级不同。 right = true && false right = true and false 的结果不一样 --- lib/rucaptcha/controller_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rucaptcha/controller_helpers.rb b/lib/rucaptcha/controller_helpers.rb index 27c5646..a5c68ca 100644 --- a/lib/rucaptcha/controller_helpers.rb +++ b/lib/rucaptcha/controller_helpers.rb @@ -18,7 +18,7 @@ module RuCaptcha end def verify_rucaptcha?(resource = nil) - right = params[:_rucaptcha].present? and session[:_rucaptcha].present? and + right = params[:_rucaptcha].present? && session[:_rucaptcha].present? && params[:_rucaptcha].downcase.strip == session[:_rucaptcha] if resource && resource.respond_to?(:errors) resource.errors.add(:base, t('rucaptcha.invalid')) unless right