Sha256: 4f343b76a731aa9946f5833326d3b68a72818f6e48dad1c59cf42259e6633ba6

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module ActiveScaffold
  module Bridges
    module Dragonfly
      module Lib
        module DragonflyBridge
          def initialize_with_dragonfly(model_id)
            initialize_without_dragonfly(model_id)
            return unless self.model.respond_to?(:dragonfly_attachment_classes) && self.model.dragonfly_attachment_classes.present?
      
            self.update.multipart = true
            self.create.multipart = true
      
            self.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)
            self.columns << field
            self.columns[field].form_ui ||= :dragonfly
            self.columns[field].params.add "remove_#{field}"
      
            [:name, :uid].each do |f|
              self.columns.exclude("#{field}_#{f}".to_sym)
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
active_scaffold-3.0.26 lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb
active_scaffold-3.0.25 lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb
active_scaffold_clarity-3.0.24.2 lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb
active_scaffold-3.0.24 lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb
active_scaffold-3.0.23 lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb
active_scaffold-3.0.22 lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb
active_scaffold-3.0.21 lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb