paperclip
https://github.com/thoughtbot/paperclip
Ruby
Easy file attachment management for ActiveRecord
Paperclip::Attachment#assign
What gets called when you call instance.attachment = File. It clears errors, assigns attributes, and processes the file. It also queues up the previous file for deletion, to be flushed away on #save of its host. In addition to form uploads, you can also assign another Paperclip attachment: new_user.avatar = old_user.avatar
Edit
git clone [email protected]:thoughtbot/paperclip.git
cd paperclip
open lib/paperclip/attachment.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Paperclip--Attachment-assign-for-pr
# Commit to gitgit add lib/paperclip/attachment.rbgit commit -m "better docs for Paperclip::Attachment#assign"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Paperclip--Attachment-assign-for-pr
hub pull-request
# Celebrate!