Sha256: 5f3e8b54235ad20f37185c3d55f2aaaf94473534aac95547d4b5a61906af2b36

Contents?: true

Size: 360 Bytes

Versions: 3

Compression:

Stored size: 360 Bytes

Contents

class Upload < ActiveRecord::Base

  has_attachment(
    :file,
    path: ':id-:style.:extension',
    styles: ->(record) {
      record.model.attachments[record.record_attribute.to_sym][:styles]
    }
  )

  validates_presence_of :file, :record_type, :record_attribute

  def model
    if record_type
      record_type.classify.constantize
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attachs-4.0.0.2 test/dummy/app/models/upload.rb
attachs-4.0.0.1 test/dummy/app/models/upload.rb
attachs-4.0.0.0 test/dummy/app/models/upload.rb