提交 ad9e52f1 编写于 作者: V Vijay Dev 提交者: Xavier Noria

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

上级 225a2482
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册