From d34fd9fd826fb658cb348eacf8b9edfce06f2b3d Mon Sep 17 00:00:00 2001 From: Caleb Wright Date: Sun, 25 Nov 2012 23:46:11 -0500 Subject: Update guides/source/active_record_validations_callbacks.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the expiration_date_cannot_be_in_the_past validation method, use `expiration_date.present?` instead of the double negative `!expiration_date.blank?`. Also join the comparisons with `&&` instead of `and`, which could cause unintended consequences. --- guides/source/active_record_validations_callbacks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/active_record_validations_callbacks.md b/guides/source/active_record_validations_callbacks.md index 0f4140b650..28f693a856 100644 --- a/guides/source/active_record_validations_callbacks.md +++ b/guides/source/active_record_validations_callbacks.md @@ -674,7 +674,7 @@ class Invoice < ActiveRecord::Base :discount_cannot_be_greater_than_total_value def expiration_date_cannot_be_in_the_past - if !expiration_date.blank? and expiration_date < Date.today + if expiration_date.present? && expiration_date < Date.today errors.add(:expiration_date, "can't be in the past") end end -- cgit v1.2.3