From ad9e52f156575f28949837a3dd0fa433fa824d57 Mon Sep 17 00:00:00 2001
From: Vijay Dev <vijaydev.cse@gmail.com>
Date: Sat, 30 Jul 2011 23:53:11 +0530
Subject: prefer to use if..end unless the condition is simple/compact

---
 .../guides/source/active_record_validations_callbacks.textile  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'railties/guides/source/active_record_validations_callbacks.textile')

diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile
index 5789d36c6d..977e736d25 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/railties/guides/source/active_record_validations_callbacks.textile
@@ -1143,8 +1143,9 @@ Here's an example where we create a class with an +after_destroy+ callback for a
 <ruby>
 class PictureFileCallbacks
   def after_destroy(picture_file)
-    File.delete(picture_file.filepath)
-      if File.exists?(picture_file.filepath)
+    if File.exists?(picture_file.filepath)
+      File.delete(picture_file.filepath)
+    end
   end
 end
 </ruby>
@@ -1162,8 +1163,9 @@ Note that we needed to instantiate a new +PictureFileCallbacks+ object, since we
 <ruby>
 class PictureFileCallbacks
   def self.after_destroy(picture_file)
-    File.delete(picture_file.filepath)
-      if File.exists?(picture_file.filepath)
+    if File.exists?(picture_file.filepath)
+      File.delete(picture_file.filepath)
+    end
   end
 end
 </ruby>
-- 
cgit v1.2.3

