如何编辑下面的代码,如果没有@ business.logo可用,则没有代码。
= image_tag @business.logo(:thumbnail), :class=> "img-rounded"
当前没有上传图片时显示:
<img alt="Thumbnail" class="img-rounded" src="http://s3.amazonaws.com/callred/businesses/logos/000/000/034/thumbnail/">
答案 0 :(得分:2)
= image_tag(@business.logo(:thumbnail), :class=> "img-rounded") if @business.logo
更新
应该问if @business.logo.present?
@business.logo
返回始终为真的Paperclip::Attachment
对象
答案 1 :(得分:1)
知道了!这是适合我的代码
- if @business.logo.present?
= image_tag @business.logo(:thumbnail), :class=> "img-rounded"