From 8e3958b9e400bfa508e01e80a06128246e5cc706 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 17 Jul 2019 19:28:06 +0800 Subject: [PATCH] allow library cover blank --- app/models/library.rb | 2 +- app/services/libraries/save_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/library.rb b/app/models/library.rb index 6029f984..90b9737e 100644 --- a/app/models/library.rb +++ b/app/models/library.rb @@ -2,7 +2,7 @@ class Library < ActiveRecord::Base include AASM belongs_to :user - belongs_to :cover, class_name: 'Attachment', foreign_key: :cover_id + belongs_to :cover, class_name: 'Attachment', foreign_key: :cover_id, optional: true has_many :library_applies, dependent: :delete_all has_many :attachments, as: :container diff --git a/app/services/libraries/save_service.rb b/app/services/libraries/save_service.rb index 88a85fc8..4b28569f 100644 --- a/app/services/libraries/save_service.rb +++ b/app/services/libraries/save_service.rb @@ -36,7 +36,7 @@ class Libraries::SaveService def validate_params! raise Error, '附件不能为空' if params[:attachment_ids].try(:compact).blank? - raise Error , '封面不能为空' if params[:cover_id].blank? + # raise Error , '封面不能为空' if params[:cover_id].blank? end def deal_library_tag!