Skip to content

iwasaki-d/administrate-field-carrierwave

 
 

Repository files navigation

Administrate::Field::Carrierwave

Code Climate

A plugin to upload and preview Carrierwave attachments in Administrate.

Usage

Add it to your Gemfile:

gem 'administrate-field-carrierwave', '~> 0.2.0'

Run:

$ bundle install

Add to your FooDashboard:

ATTRIBUTE_TYPES = {
  bar: Field::Carrierwave.with_options(
    image: :standard,
    multiple: true,
    image_on_index: true
  )
}.freeze

To handle multiple asset uploads, the attribute must point to an empty array in a hash:

# If multiple: true
def permitted_attributes
  super - [:bar] + [{ bar: [] }]
end

Options

  • image (default: nil): a version that will be displayed in an <img> element.
  • image_on_index (default: false): whether or not to show the image itself on the index list view. The default behavior (when false) is to display a "View" link that opens the image in a new tab/window when clicked.
  • multiple (default: false): allows uploading of multiple files. ATTENTION 🚨: requires CarrierWave’s master branch. Uploaded files will replace the current ones – if present – and not add to them.

About

Administrate::Field::Carrierwave is maintained by z.productions.

See also the list of contributors who participated in this project.

About

A plugin to upload and preview Carrierwave attachments in Administrate

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 69.4%
  • HTML 30.6%