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-04 16:41:27 -0700
commit54e7694982510e22810c064ae3594f74209c94b9 (patch)
tree73424a7bb542170cfd2de604cae435d1bb3edfb7
parent29772a136a6f148f3cc27ddfccc29bd9ddc672e3 (diff)
downloadrails-54e7694982510e22810c064ae3594f74209c94b9.tar.gz
rails-54e7694982510e22810c064ae3594f74209c94b9.tar.bz2
rails-54e7694982510e22810c064ae3594f74209c94b9.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>