From a4376c9aa3622b95f62a1bdb1df5c386f64e6215 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 10 Feb 2020 13:24:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/live_links_controller.rb | 9 ++++++--- config/routes.rb | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) 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