Ruby HTML
Switch branches/tags
Clone or download

README.md

Administrate::Field::Paperclip

A plugin to integrate Paperclip fields in Administrate.

Instructions

Add administrate-field-paperclip and paperclip to your Gemfile:

gem 'administrate-field-paperclip'
gem 'paperclip'

Install:

$ bundle install

Usage

Follow the instructions on Paperclip to get started with your models and migrations. Once you've added the Paperclip attribute to your models, edit your Administrate dashboards. If you added 'avatar' to 'User', then you should:

class UserDashboard < Administrate::BaseDashboard
  ATTRIBUTE_TYPES = {
    avatar: Field::Paperclip,
  }
# ...

Then add :avatar to FORM_ATTRIBUTES, SHOW_PAGE_ATTRIBUTES and (optionally) COLLECTION_ATTRIBUTES.

You can provide the field with options using Field::Paperclip.with_options(options):

  • thumbnail_style (defaults to 'thumbnail') to control what image style is used to display the image in collection views
  • big_style (defaults to 'original') to control what image style is used to display the image on the show page.
  • url_only (defaults to false) to show only a URL (as a link) instead of trying to display an image.

Contributors

Based on the Administrate::Field::Image template.