繁体   English   中英

如何从我的索引文件中查看活动存储上传的图像,出现此错误

[英]how do i view an active storage uploaded image from my index file, this error comes up

<%= image_tag (complaint.image) %> 此行产生此错误,无法将图像解析为 URL:to_model 委托给附件,但附件为 nil 没有 image_tag,我得到一个 active_storage object; #,那我要怎么过去呢

只需在显示图像之前检查它是否为零。

<%= image_tag(complaint.image) if complaint.image %>

也不要在 Ruby 中的方法名称和括号之间放置空格。 由于括号在 Ruby 中是可选的,因此它将被视为单个参数,而不是 arguments 的列表。

foo (bar, baz) # causes a syntax error

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM