Sha256: fa31243e633693260bb10b70dc68ee9ec3099fcf2744d166d4fd1e7c6053aa88

Contents?: true

Size: 1 KB

Versions: 30

Compression:

Stored size: 1 KB

Contents

module ActiveScaffold
  module Bridges
    class Paperclip
      module PaperclipBridge
        def initialize(model_id)
          super
          return unless model.respond_to?(:attachment_definitions) && !model.attachment_definitions.nil?

          update.multipart = true
          create.multipart = true

          model.attachment_definitions.each_key do |field|
            configure_paperclip_field(field.to_sym)
            # define the "delete" helper for use with active scaffold, unless it's already defined
            ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.generate_delete_helper(model, field)
          end
        end

        private

        def configure_paperclip_field(field)
          columns << field
          columns[field].form_ui ||= :paperclip
          columns[field].params.add "delete_#{field}"

          %i[file_name content_type file_size updated_at].each do |f|
            columns.exclude("#{field}_#{f}".to_sym)
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
active_scaffold-3.7.8 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.7.7 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.7.6 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.7.5 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.7.2 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.7.1 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.7.0 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.20 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.19 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.17 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.15 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.14 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.13 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.12 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.11.1 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.11 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.10 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.9 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.8 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb
active_scaffold-3.6.6 lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb