diff --git a/app/controllers/live_links_controller.rb b/app/controllers/live_links_controller.rb index 29233e37b..f4b49d4aa 100644 --- a/app/controllers/live_links_controller.rb +++ b/app/controllers/live_links_controller.rb @@ -2,7 +2,7 @@ class LiveLinksController < ApplicationController before_action :require_login before_action :find_course, only: [:index, :create] before_action :user_course_identity, :teacher_allowed, only: [:create] - before_action :edit_auth, only: [:edit, :update] + before_action :edit_auth, only: [:edit, :update, :destroy] def index lives = @course.live_links @@ -34,8 +34,6 @@ class LiveLinksController < ApplicationController # 开启时发送消息,关闭直播时删除对应的消息 if params[:on_status].to_i == 1 LivePublishJob.perform_later(current_live.id) - else - current_live.tidings.destroy_all end end else @@ -44,6 +42,11 @@ class LiveLinksController < ApplicationController render_ok end + def destroy + current_live.destroy! + render_ok + end + private def create_params diff --git a/config/routes.rb b/config/routes.rb index f0c91e8f9..63a6e4494 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -550,7 +550,7 @@ Rails.application.routes.draw do end end - resources :live_links, only: [:index, :update, :create, :edit], shallow: true + resources :live_links, only: [:index, :update, :create, :edit, :destroy], shallow: true resources :homework_commons, shallow: true do