From 5b700a15e10397a48fc9b66869d580b094ebcd26 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 21:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b4604892d..c1fa48be8 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -192,11 +192,15 @@ class FilesController < ApplicationController end end else + tip_exception("资源名称不能为空") if params[:name].blank? + tip_exception("资源名称不能超过60个字符") if params[:name].strip.length > 60 + tip_exception("链接地址不能为空") if params[:link].blank? attachment = Attachment.new attachment.container = @course attachment.course_second_category_id = course_second_category_id - attachment.filename = params[:name] - attachment.link = params[:link] + attachment.author_id = current_user.id + attachment.filename = params[:name].strip + attachment.link = params[:link].strip attachment.description = params[:description] attachment.is_public = params[:is_public] && @course.is_public == 1 ? 1 : 0 attachment.is_publish = @atta_is_publish