Skip to content

Instantly share code, notes, and snippets.

@joshfrench
Created April 7, 2010 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfrench/359271 to your computer and use it in GitHub Desktop.
Save joshfrench/359271 to your computer and use it in GitHub Desktop.
/ 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
# 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