1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

This commit is contained in:
Vijay Dev 2011-07-30 23:53:11 +05:30 committed by Xavier Noria
parent 225a2482c1
commit ad9e52f156

View file

@ -1143,8 +1143,9 @@ Here's an example where we create a class with an +after_destroy+ callback for a
<ruby> <ruby>
class PictureFileCallbacks class PictureFileCallbacks
def after_destroy(picture_file) 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
end end
</ruby> </ruby>
@ -1162,8 +1163,9 @@ Note that we needed to instantiate a new +PictureFileCallbacks+ object, since we
<ruby> <ruby>
class PictureFileCallbacks class PictureFileCallbacks
def self.after_destroy(picture_file) 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
end end
</ruby> </ruby>