多个回形针 default_urls [英] Multiple Paperclip default_urls

查看:58
本文介绍了多个回形针 default_urls的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Paperclip 将图像上传到我的项目模型,并且我想要一组默认图像(不取决于样式,而是不同的图像)这可能吗?要将一个数组而不是一个 URL 传递给 :default_url 选项?

I am using Paperclip to upload an image to my Project model and I want to have an array of default images (not depending on the style, but different images) is that posible? To pass an array instead of just one URL to the :default_url option?

谢谢,

尼古拉斯·霍克·伊萨

推荐答案

非常接近:如果您希望图像随机更改,而不仅仅是在模型第一次加载时:

So close: If you want the images to change randomly, and not just on first load of the model:

:default_url => lambda { "path/to/images/#{rand(5)}.jpg" }

这篇关于多个回形针 default_urls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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