From bd34b956669f8c94a0454dbf209c566a91bf1a5d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 25 Dec 2019 13:36:22 +0800 Subject: [PATCH] =?UTF-8?q?OJ=E5=88=A0=E9=99=A4=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hacks_controller.rb | 5 +++++ app/models/hack.rb | 11 ----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index cb2e67922..d2dcbe145 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -132,6 +132,11 @@ class HacksController < ApplicationController def destroy @hack.destroy + base_attrs = { + user_id: user_id, viewed: 0, tiding_type: 'System', trigger_user_id: current_user.id, + parent_container_type: "HackDelete" + } + @hack.tidings.create!(base_attrs) render_ok end diff --git a/app/models/hack.rb b/app/models/hack.rb index e1b2b225e..b94eddbd2 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -23,8 +23,6 @@ class Hack < ApplicationRecord scope :opening, -> {where(open_or_not: 1)} scope :mine, -> (author_id){ where(user_id: author_id) } - after_destroy :send_delete_tiding - def language if hack_codes.count == 1 hack_codes.first.language @@ -53,13 +51,4 @@ class Hack < ApplicationRecord user_id == user.id || user.admin_or_business? end - private - def send_delete_tiding - base_attrs = { - user_id: user_id, viewed: 0, tiding_type: 'System', trigger_user_id: User.current.id, - parent_container_type: "HackDelete" - } - tidings.create!(base_attrs) - end - end