nil在视图中使用变量之前,请务必检查变量是否正确.
<% image_tag this.profile.expiring_url(180) unless this.profile.nil? %>
Run Code Online (Sandbox Code Playgroud)
我确信这个问题有一个更优雅的解决方案,但这应该让你开始.
这也应该有用
<%= image_tag(this.profile.expiring_url(180)) rescue "no image!" %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2047 次 |
| 最近记录: |