使用 Image_tag,如果加载失败则呈现替代方案

using Image_tag, render an alternative if the load fail

我正在使用 rails 5.2.4 的活动存储,我的附件名为照片,如果图像加载失败(例如图像被删除),我想渲染 "default.jpg"来自存储),谢谢

    <%= image_tag'batman.png', alt: 'hello', :onerror => "this.src='hulk.png'"  %>