fleshyorgans

tryin’ not to be a linux fanboy

fleshyorgans Two Cats

Quick and dirty hack for acts_as_attachment file movement

December 10th, 2007 · No Comments

Say you’re working on something that uses acts_as_attachment. Also say that the person who wrote it decided that all the different models’ attachments would save in the same place. Also suppose that you want to change the file location of all those uploads.

Well, here’s a quick and dirty migration that’ll save you from moving files manually.

Automove Files for Storage Changes, with acts_as_attachment

Originally I wanted to do something like Attachment.new( OldAttachment.find(?).attributes ), but there were issues with that because acts_as_attachment wants uploaded data to be a tmp file or some crap. This ended up being the easier way, all in all.

Use with care.

Tags: ,

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment