Sha256: e8437952ccbb853f083b4c90a88499951153a4a371c3b6e9e782557aacea52a5

Contents?: true

Size: 807 Bytes

Versions: 4

Compression:

Stored size: 807 Bytes

Contents

module ActiveScaffold
  module Bridges
    class Dragonfly
      module DragonflyBridge
        def initialize(model_id)
          super
          return unless model.respond_to?(:dragonfly_attachment_classes) && model.dragonfly_attachment_classes.present?

          update.multipart = true
          create.multipart = true

          model.dragonfly_attachment_classes.each do |attachment|
            configure_dragonfly_field(attachment.attribute)
          end
        end

        private

        def configure_dragonfly_field(field)
          columns << field
          columns[field].form_ui ||= :dragonfly
          columns[field].params.add "remove_#{field}"

          %i[name uid].each do |f|
            columns.exclude(:"#{field}_#{f}")
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_scaffold-4.0.0 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-4.0.0.rc3 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-4.0.0.rc2 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-4.0.0.rc1 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb