我正在尝试使用多态关联和 Shrine 实现多个文件上传。
class Campaign < ApplicationRecord
has_many :photos, as: :imageable, dependent: :destroy
accepts_nested_attributes_for :photos, allow_destroy: true
end
class Photo < ApplicationRecord
include ImageUploader::Attachment.new(:image)
belongs_to :imageable, polymorphic: true
end
浏览完文档后,我可以保存照片。
请告知如何在可成像范围内验证图像的唯一性。
我知道每个原始版本都可以生成一个签名,但这是正确的方法吗?
谢谢。