make Attachment#make_childless safe to call more often
i.e. if it's already a child, or it has no children, and you don't want to check those beforehand Change-Id: Ie0568c980f888b1e39f64aa0108033222887b2b6 Reviewed-on: https://gerrit.instructure.com/97612 Tested-by: Jenkins Reviewed-by: Rob Orton <rob@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
0e18d33f2d
commit
cf3159e445
|
@ -1213,7 +1213,9 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def make_childless(preferred_child = nil)
|
||||
return if root_attachment_id
|
||||
child = preferred_child || children.take
|
||||
return unless child
|
||||
raise "must be a child" unless child.root_attachment_id == id
|
||||
child.root_attachment_id = nil
|
||||
child.filename = filename if filename
|
||||
|
|
Loading…
Reference in New Issue