How should I write:
if @parent.child.grand_child.attribute.present?
do_something
without cumbersome nil checkings to avoid exception:
if @parent.child.present? && @parent.child.grandchild.present? && @parent.child.grandchild.attribute.present?
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…