Rails 5 Carrierwave Uploader undefined method `to_sym' for [:photo_one, :photo_two, :photo_three]:Array 你的意思是? to_s to_yaml to_s等

Rails 5 Carrierwave Uploader undefined method `to_sym' for [:photo_one, :photo_two, :photo_three]:Array Did you mean? to_s to_yaml to_set

我的模型有三列,用于上传图片和文档。我正在使用 Rails 5.1.4Carrierwave 1.0。我不想要一个接受多个上传作为数组的列,所以我决定只有三个单独的上传选项,并尝试使用同一个上传器。

我不断收到 undefined methodto_sym' for [:photo_one, :photo_two, :photo_three]:Array 你是说吗? to_s to_yaml to_set` 错误,经过数小时的搜索似乎无法弄清楚。我确实觉得我的上传者错了,但我目前的知识水平很难确定。

models/plaqueorder.rb

class Plaqueorder < ApplicationRecord
  mount_uploader [:photo_one, :photo_two, :photo_three], DocumentUploader
  belongs_to :user
end

uploaders/document_uploader.rb

class DocumentUploader < CarrierWave::Uploader::Base
  storage :file

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}"
  end

  version :thumb do
    process resize_to_fit: [100, 50]
  end

  def extension_white_list
    %w(jpg jpeg gif png pdf)
  end
end

您需要为每个字段单独定义上传者。如果您浏览 mount_uploader sources,您会看到不支持的列数组