Sha256: 8142863e7583a93647ff45ebcdaf31d24f40bf32a402ad3f68395812d821361f

Contents?: true

Size: 965 Bytes

Versions: 29

Compression:

Stored size: 965 Bytes

Contents

module ActiveScaffold
  module Bridges
    class Dragonfly
      module DragonflyBridge
        def initialize_with_dragonfly(model_id)
          initialize_without_dragonfly(model_id)
          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

        def self.included(base)
          base.alias_method_chain :initialize, :dragonfly
        end

        private

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

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

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
active_scaffold-3.4.43 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.42 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.41.1 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.41 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.40 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.39 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.38 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.37 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.36 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.35 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.34 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.33 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.32 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.31 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.30 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.29 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.28 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.27 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.26 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb
active_scaffold-3.4.25 lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb