<%= image_tag (complaint.image) %>这一行孕育发生了这个错误,无法将图片解析成URL:to_model委派给attachment,但attachment是nil 没有image_tag,我得到一个active_storage对象;# ,那么我怎么才能通过这个问题呢?
在显示图片之前,请检查它是否为nil。
<%= image_tag(complaint.image) if complaint.image %>
另外,在Ruby中,不要在方法名和parens之间加上空格。因为在Ruby中,parens是可选的,它将被视为一个单一参数,而不是一个参数列表。
foo (bar, baz) # causes a syntax error