Carrierwave:如何处理同一类型的多个上传

发布于 2024-10-21 05:52:25 字数 147 浏览 0 评论 0原文

目前,我有一个带有一个载波上传器的文章模型,要求已更改,每篇文章都应附加 n 个图像。

实现这一目标的最佳(也是最简单)方法是什么?现在,我能想到的就是创建一个图像实体并引用上传者并让每一篇文章n图像。听起来工作量很大,并且会破坏所有当前图像,所以我不赞成这样做。

currently I am having an Article model with one carrierwave uploader, requirements have changed and every Article should have n images attached.

What is the best (and most simple) way to achieve this? Right now, all I can think of is creating an Image entity and have this reference the uploader and let have every Article n Images. Sounds like a lot of work and would break all current images, so I would not favor this.

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

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

发布评论

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

评论(1

善良天后 2024-10-28 05:52:25

如果您确实将图像上传要求拆分到自己的模型中可能会更好。您的文章模型已经更改了需求,并且您以后可能会有其他需要类似功能的模型。

从软件设计的角度来看,拥有一个处理上传并将其与文章模型相关联的图像模型是一种更易于维护的方式。

It might be better if you do split out the image uploading requirements into its own model. Your Article model has already changed the requirements and you might have other models needing similar functionality later on.

From the software design point of view, having an Image model that deals with uploading and relating that to an Article model is a more maintainable way.

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