Carrierwave:如何处理同一类型的多个上传
目前,我有一个带有一个载波上传器的文章模型,要求已更改,每篇文章都应附加 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确实将图像上传要求拆分到自己的模型中可能会更好。您的文章模型已经更改了需求,并且您以后可能会有其他需要类似功能的模型。
从软件设计的角度来看,拥有一个处理上传并将其与文章模型相关联的图像模型是一种更易于维护的方式。
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.