public
Description: This plugin when used in conjunction with the paperclip file attachment plugin allows you to attach more than one file to the model.
Homepage:
Clone URL: git://github.com/heavysixer/paperclippolymorph.git
Click here to lend your support to: paperclippolymorph and make a donation at www.pledgie.com !
name age message
file MIT-LICENSE Sat Jun 28 16:20:20 -0700 2008 initial commit [heavysixer]
file README.textile Sun Jun 29 06:27:14 -0700 2008 fixed a small typo in the readme [heavysixer]
directory generators/ Tue Mar 31 09:34:00 -0700 2009 the usage instructions were wrong. [Mark Daggett]
file init.rb Sat Jun 28 16:20:20 -0700 2008 initial commit [heavysixer]
directory lib/ Tue Apr 07 07:37:04 -0700 2009 we need to ensure that we return the result of ... [Mark Daggett]
directory spec/ Thu Nov 06 07:29:00 -0800 2008 schema change to allow for latest paperclip fro... [aunderwo]
README.textile

PaperclipPolymorph

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.

The Paperclip Plugin must also be installed for PolyMorphicPaperclip to work.
Get paperclip here:
http://thoughtbot.com/projects/paperclip

Example

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
end

essay.assets.attach(asset)
essay.assets.asset.detach -or- @essay.assets.detach(asset)

Helper methods

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