Created
April 7, 2010 18:42
-
-
Save joshfrench/359271 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ Very basic file attachment via a page part. When rendered, this part will | |
/ output the path to its attached document. | |
/ Provide a view partial for the page-edit form: | |
.row= file_field_tag "page[parts_attributes][#{page_part_counter}][document]" | |
- if page_part.document.file? | |
.row= page_part.document.original_filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# And the class definition: | |
class FilePagePart < PagePart | |
has_attached_file :document | |
def render_content | |
self.document.url | |
end | |
end | |
# I'm leaving out the creation of the paperclip columns (easy) and any display | |
# sugar (thumbnail, file removal) but you can see more complete examples at | |
# http://github.com/digitalpulp/radiant-page-parts-extension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment