heavysixer / paperclippolymorph
- Source
- Commits
- Network (10)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
3998289
commit 39982898ee805b60f5c0bc82854c2b309fd114ad
tree 3e6bb7c1507175dffd49c75e4ebcaa9adcdcc139
parent da4f282c7ab1389789a47b3e5a82a701372c1cb5
tree 3e6bb7c1507175dffd49c75e4ebcaa9adcdcc139
parent da4f282c7ab1389789a47b3e5a82a701372c1cb5
| name | age | message | |
|---|---|---|---|
| |
.DS_Store | ||
| |
MIT-LICENSE | Sat Jun 28 16:20:20 -0700 2008 | |
| |
README.textile | Sun Jun 29 06:27:14 -0700 2008 | |
| |
generators/ | ||
| |
init.rb | Sat Jun 28 16:20:20 -0700 2008 | |
| |
lib/ | ||
| |
spec/ |
README.textile
Copyright © 2008 PolymorphicPaperclip Mark Daggett, released under the MIT license
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


