From b9b3a303a751bda315e0bdd228626d4cbdba3410 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 10 Dec 2019 11:06:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E9=80=89=E7=94=A8=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index a918f4e0a..292a409af 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -35,7 +35,7 @@ class Attachment < ApplicationRecord def title title = filename - if container.is_a?(StudentWork) && author_id != User.current.id + if container && container.is_a?(StudentWork) && author_id != User.current.id course = container&.homework_common&.course unless User.current.teacher_of_course?(course) title = "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{DCODES.sample(8).join}" + File.extname(filename)