aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-07-30 23:53:11 +0530
committerXavier Noria <fxn@hashref.com>2011-08-13 16:22:12 -0700
commitad9e52f156575f28949837a3dd0fa433fa824d57 (patch)
treedd74ce31808ec2790adc9f2d22b717456407e9fe
parent225a2482c19fa3a1acdc05371a44b090c6cb4d7c (diff)
downloadrails-ad9e52f156575f28949837a3dd0fa433fa824d57.tar.gz
rails-ad9e52f156575f28949837a3dd0fa433fa824d57.tar.bz2
rails-ad9e52f156575f28949837a3dd0fa433fa824d57.zip
prefer to use if..end unless the condition is simple/compact
-rw-r--r--railties/guides/source/active_record_validations_callbacks.textile10
1 files changed, 6 insertions, 4 deletions
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>