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