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:
parent
225a2482c1
commit
ad9e52f156
1 changed files with 6 additions and 4 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue