Sha256: 2ed2aacbbce6e50f3cabfbd6bb64fc03e801415d11668a87d3112793ea790e9d

Contents?: true

Size: 368 Bytes

Versions: 3

Compression:

Stored size: 368 Bytes

Contents

class Upload < ActiveRecord::Base

  has_attachment(
    :file,
    path: 'uploads/: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 lib/generators/attachs/upload/templates/model.rb
attachs-4.0.0.1 lib/generators/attachs/upload/templates/model.rb
attachs-4.0.0.0 lib/generators/attachs/upload/templates/model.rb