Skip to content

Instantly share code, notes, and snippets.

@digitalpulp
Created April 12, 2010 14:16
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 digitalpulp/363600 to your computer and use it in GitHub Desktop.
Save digitalpulp/363600 to your computer and use it in GitHub Desktop.
.row= file_field_tag "page[parts_attributes][#{page_part_counter}][document]"
- if page_part.document.file?
.row= page_part.document.original_filename
class FilePagePart < PagePart
has_attached_file :document
def render_content
self.document.url
end
end
@digitalpulp
Copy link
Author

A page part for basic file uploads using Paperclip. Custom page parts consist of a model and a view partial used for the page-edit form.

In this case, the form elements are simply a file field and, if we already have a saved file, its filename. Note the render_content method: when this part is rendered, it will output the path to its file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment