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