载波检索从mount_uploaders挂载点缓存的缓存文件

时间:2018-10-26 18:32:41

标签: ruby-on-rails carrierwave

我有一个多页表单,因此我需要缓存图像并在以后检索它们。对于mount_uploader挂载点,我没有问题。

假设我有这个模型:

class MyModel < ApplicationRecord
  mount_uploader :other_image, ImageUploader
  mount_uploaders :images, ImageUploader

  attr_accessor :other_image_cache_name, :images_cache_names
end

def save
  other_image.retrieve_from_cache!(other_image_cache_name)
  # Need to retrieve :images_cache_names into :images
  super
end

在用户发布表单后,在我的控制器中,我将图像缓存如下:

def cache_images
  @mymodel.other_image_cache_name = @mymodel.other_image.cache_name

  @mymodel.images_cache_names = @house.images.map {|image| image.cache_name}
end

那么,如何将images_cache_names中的缓存名称(即缓存名称的数组)检索到:images中?

注意::images是一个数组,而不是ImageUploader,所以我不能调用#retrieve_from_cache!在上面。

0 个答案:

没有答案
相关问题