Sha256: f87adca1e1aaaace3f974bfa36ce76c513a4ea3b6b1012e992814e73b41ea85f

Contents?: true

Size: 1.76 KB

Versions: 47

Compression:

Stored size: 1.76 KB

Contents

ActiveScaffold::DataStructures::Column.class_eval do
  attr_accessor :file_column_display
end

module ActiveScaffold::Config
  class Core < Base
    attr_accessor :file_column_fields
    def initialize_with_file_column(model_id)
      initialize_without_file_column(model_id)
      
      return unless ActiveScaffold::Bridges::Paperclip::Lib::FileColumnHelpers.klass_has_file_column_fields?(self.model)
      
      self.model.send :extend, ActiveScaffold::Bridges::Paperclip::Lib::FileColumnHelpers
      
      # include the "delete" helpers for use with active scaffold, unless they are already included
      self.model.generate_delete_helpers
      
      # switch on multipart
      self.update.multipart = true
      self.create.multipart = true
      
      self.model.file_column_fields.each{ |field|
        configure_file_column_field(field)
      }
    end
    
    alias_method_chain :initialize, :file_column unless self.instance_methods.include?("initialize_without_file_column")
    
    def configure_file_column_field(field)
      # set list_ui first because it gets its default value from form_ui
      self.columns[field].list_ui ||= self.model.field_has_image_version?(field, "thumb") ? :thumbnail : :download_link_with_filename
      self.columns[field].form_ui ||= :file_column
      
      # these 2 parameters are necessary helper attributes for the file column that must be allowed to be set to the model by active scaffold.
      self.columns[field].params.add "#{field}_temp", "delete_#{field}"
      
      # set null to false so active_scaffold wont set it to null
      # delete_file_column will take care of deleting a file or not.
      self.model.columns_hash[field.to_s].instance_variable_set("@null", false)
      
    rescue
      false
    end
    
  end
end

Version data entries

47 entries across 47 versions & 4 rubygems

Version Path
active_scaffold_vho-3.0.30 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.29 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.1.6 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.28 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.1.5 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.27 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.1.4 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.26 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.25 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.1.3 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.1.2 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold-3.0.26 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.1.1 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold-3.0.25 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.24 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_clarity-3.0.24.2 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.1.0 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.23 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold_vho-3.0.22 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb
active_scaffold-3.0.24 lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb