简体   繁体   English

Rails-如何将回形针模型移动到另一个模型

[英]Rails - How to Move a PaperClip Model to Another Model

Rails 3 app with paperclip. 带回形针的Rails 3应用程序。

Given a Paperclip File Model, how can you move that paperclip File to different paperclip, say image gallery? 给定一个回形针文件模型,如何将那个回形针文件移动到其他回形针,例如图像库? Which would have different processing rules etc? 哪个会有不同的处理规则等?

Any ideas? 有任何想法吗?

I've just tried the following: 我刚刚尝试了以下方法:

Given two models, with a picture attachment and their own Paperclip configurations, say: Gallery1 and Gallery2. 给定两个带有picture附件和自己的回形针配置的模型,例如:Gallery1和Gallery2。

Given I had one object in Gallery1 with a picture already attached. 鉴于我在Gallery1中有一个对象,并且已经附加了图片。

Make: 使:

Gallery2.create(:picture => Gallery1.first.picture)

And it creates the picture properly resized with the constraints of Gallery2. 并创建在Gallery2约束下适当调整大小的图片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM