Module: AbAdmin::Concerns::Fileuploads::SingletonMethods

Defined in:
lib/ab_admin/concerns/fileuploads.rb

Instance Method Summary collapse

Instance Method Details

#fileuploads(*args) ⇒ Object

Join ActiveRecord object with uploaded file Usage:

class Article < ActiveRecord::Base
  has_one :picture, as: :assetable, dependent: :destroy

  fileuploads :picture
end

19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ab_admin/concerns/fileuploads.rb', line 19

def fileuploads(*args)
  class_attribute :fileuploads_columns, instance_writer: false
  self.fileuploads_columns = args

  unless self.is_a?(ClassMethods)
    include InstanceMethods
    extend ClassMethods

    after_create :fileuploads_update, if: :fileupload_changed?
  end
end