使用rails_admin 上传多个图像(Attachment_fu、Carrierwave 等)?有什么解决办法吗?

发布于 2025-01-05 01:24:45 字数 121 浏览 6 评论 0原文

我正在寻找一种使用 Rails Admin 在一个模型上拥有多个附件的简单方法。我已经使用了回形针,但我需要多张图像,而不仅仅是一张。

有任何提示/想法/链接吗?

非常感谢!

奥莱

I'm looking for a easy way to have multiple attachments on one model using Rails Admin. I've already Paperclip working, but I need multiple images and not just one.

Any hints / ideas / links?

Thank you very much!

Ole

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫尐诺 2025-01-12 01:24:45

假设您有一个用户想要很多照片:

class User
  has_many :photos
end

class Photo
  belongs_to :user
  has_attached_file :image
  #or
  mount :image, ImageUploader
end

因此您不会要求您的 Carrierwave 或回形针模型拥有多个文件,而是拥有许多属于您的 Rails 模型的回形针模型。

Let's say that you have a user who wants many photos:

class User
  has_many :photos
end

class Photo
  belongs_to :user
  has_attached_file :image
  #or
  mount :image, ImageUploader
end

So you don't ask your carrierwave or paperclip model to have multiple files, you instead have many paperclip models belonging to your rails model.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文