This plugin allows users of the Paperclip plugin to easily share attached files between multiple models. Essentially, polymorphic paperclip transparently saves the attached files into a separate asset’s table and associates the the model to the asset through a polymorphic_attachings_ table.
This fork treats the attaching as a list. It also assumes your project has the acts_as_list plugin installed.
The Paperclip Plugin must also be installed for PolyMorphicPaperclip to work. Get paperclip here: http://thoughtbot.com/projects/paperclip
class PhotoEssay < ActiveRecord::Base acts_as_polymorphic_paperclip end
You can also add a counter_cache to your model if you wish.
class Essay < ActiveRecord::Base
acts_as_polymorphic_paperclip :counter_cache => true
essay.assets.asset.detach -or- @essay.assets.detach(asset)
There is one helper method so far used to determine if the asset can be displayed in a browser
@essay.assets.first.browser_safe? # => returns true or false
Copyright © 2008 PolymorphicPaperclip Mark Daggett, released under the MIT license