Skip to content
Browse files

prefer to use if..end unless the condition is simple/compact

  • Loading branch information...
1 parent 225a248 commit ad9e52f156575f28949837a3dd0fa433fa824d57 @vijaydev vijaydev committed with fxn Jul 30, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 railties/guides/source/active_record_validations_callbacks.textile
View
10 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>

0 comments on commit ad9e52f

Please sign in to comment.
Something went wrong with that request. Please try again.