如何知道图片是否已上传?- 回形针 [英] How to know if an image has been uploaded or not? - Paperclip

查看:58
本文介绍了如何知道图片是否已上传?- 回形针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道有没有办法知道图片是否上传了?

do you know if is there a method to know if the image has been uploaded?

我的意思是,我有一个 Foo_Class,这个类可以有一个附加的图像,但它的存在不是必需的.有没有办法知道该类的特定实例是否有图像?

I mean, i have a Foo_Class, and this class can have an attached image, but its presence is not necessary. Is there a way to know if a particular instance of that class have the image or not?

谢谢!

推荐答案

当您将 Paperclip 添加到模型时,您添加了 paperclip 特定行,我的是

When you added Paperclip to your model you added paperclip specific rows, mine are

cover_file_name
cover_content_type
cover_file_size
cover_updated_at

然后我检查它是否为零

 Foo_Class.cover_file_name.nil? 

这篇关于如何知道图片是否已上传?- 回形针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆