Module: Extensions::Materials::ActiveRecord::Base::ClassMethods

Defined in:
lib/extensions/materials/active_record/base.rb

Instance Method Summary collapse

Instance Method Details

#has_one_folderObject

Declare this to allow models to support materials uploads.


5
6
7
8
9
10
11
12
13
# File 'lib/extensions/materials/active_record/base.rb', line 5

def has_one_folder # rubocop:disable Naming/PredicateName
  after_initialize :build_new_record_folder, if: :new_record?

  has_one :folder, as: :owner, class_name: Course::Material::Folder.name,
                   inverse_of: :owner, dependent: :destroy, autosave: true
  has_many :materials, through: :folder, class_name: Course::Material.name

  include Extensions::Materials::ActiveRecord::Base::InstanceMethods
end