Install and configure following the Paperclip installation instructions
Configure the migration to use Paperclip for a specific field, in the example bellow Paperclip will be used to upload a file to image
attribute.
create_table :photos do |t|
t.attachment :image
t.string :title
t.references :person, index: true
t.timestamps
end
Configure the model to use Paperclip for a specific field, in the example bellow Paperclip will be used to upload a file to image
attribute.
class Photo < ActiveRecord::Base
has_attached_file :image, styles: { medium: '640x480>', thumb: '160x120>' }, default_url: 'missing.png'
validates_attachment :image, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"] }
end
In your presenter use the admin_previewable_file input to handle the field configures with paperclip.
field :image,
actions: [:new, :edit, :show],
as: :admin_previewable_file
Example of the rendered edit form:
- Carnivel Sample Application on Github
- Sample Presenter source code using the Paperclip Integration - Photo Presenter
- Home application carnival.vzr.com.br
- CRUD using Paperclip carnival.vzr.com.br/people