From b374534fa19c96d18b32ae9b5e5f48ee97b56b5a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 12 Mar 2020 19:40:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=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 | 6 +++--- app/models/attachment.rb | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) 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个字符"