diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 362523a7d..e40c986ca 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -43,7 +43,7 @@ class FilesController < ApplicationController @attachments = @attachments.by_keywords(params[:search]) if params[:no_link] - @attachments = @attachments.where(link: nil) + @attachments = @attachments.no_link end @attachments = @attachments.page(@page).per(@page_size) @@ -142,7 +142,7 @@ class FilesController < ApplicationController end def public_with_course_and_project - @attachments = Attachment.publiced.simple_columns + @attachments = Attachment.publiced.no_link.simple_columns .contains_course_and_project .includes(:container, author: :user_extension) .by_filename_or_user_name(params[:search]) @@ -155,7 +155,7 @@ class FilesController < ApplicationController def mine_with_course_and_project @current_user = current_user - @attachments = Attachment.mine(current_user) + @attachments = Attachment.mine(current_user).no_link .simple_columns .contains_course_and_project .by_keywords(params[:search]) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 1a9b50c3b..001883fb6 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -25,6 +25,7 @@ class Attachment < ApplicationRecord scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} scope :published, -> {where(is_publish: 1)} + scope :no_link, -> {where(link: nil)} validates_length_of :description, maximum: 100, message: "不能超过100个字符"