开发者

Rails - Using Paperclip to temporarily store files and then move to another model

How is this possible to do?

When a user upload files, I want to upload the file to an AttachmentTemp model using paperclip, and use some type of temp folder on S3.

Then in my delayed job, use t开发者_StackOverflow中文版hat temp file, but save that file to the Attachment model paperclip where it can be processed via delayed_job.

Possible?


I haven't tried it, but how about the following?

First, run the Paperclip generator for both models, so both tables have the necessary columns in the database (post migration).

Then use the Temp model in your user-facing new action/view.

Later, in your delayed job, load up each AttachmentTemp instance (filtered on some status criterion) and copy each one to an Attachment instance. So you're just translating one to the other.

In your remaining user-facing actions, use Attachment instances (so AttachmentTemps are only used when first creating a record).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜