このコミットが含まれているのは:
@@ -9,6 +9,10 @@ class Material < ApplicationRecord
|
||||
belongs_to :tag, optional: true
|
||||
belongs_to :created_by_user, class_name: 'User', optional: true
|
||||
belongs_to :updated_by_user, class_name: 'User', optional: true
|
||||
belongs_to :file_suppressed_by_user, class_name: 'User', optional: true
|
||||
|
||||
has_many :material_versions, dependent: :destroy
|
||||
has_many :material_export_items, dependent: :destroy
|
||||
|
||||
has_one_attached :file, dependent: :purge
|
||||
|
||||
@@ -18,11 +22,18 @@ class Material < ApplicationRecord
|
||||
validate :tag_must_be_material_category
|
||||
|
||||
def content_type
|
||||
return nil if file_suppressed?
|
||||
return nil unless file&.attached?
|
||||
|
||||
file.blob.content_type
|
||||
end
|
||||
|
||||
def file_suppressed? = file_suppressed_at.present?
|
||||
|
||||
def snapshot_export_paths
|
||||
material_export_items.order(:profile).pluck(:profile, :export_path).to_h
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def file_must_be_attached
|
||||
|
||||
新しい課題から参照
ユーザをブロックする