diff --git a/app/services/create_watch_video_service.rb b/app/services/create_watch_video_service.rb index 8a9bb7f08..afdd57b5b 100644 --- a/app/services/create_watch_video_service.rb +++ b/app/services/create_watch_video_service.rb @@ -38,9 +38,9 @@ class CreateWatchVideoService < ApplicationService end else # 开始播放时记录一次 - if params[:course_video_id].present? + if params[:course_id].present? # 课堂视频 - course_video = CourseVideo.find(params[:course_video_id]) + course_video = CourseVideo.find_by(video_id: params[:video_id], course_id: params[:course_id]) watch_course_video = WatchCourseVideo.find_or_initialize_by(course_video_id: course_video.id, user_id: user.id) do |d| d.start_at = current_time d.duration = params[:duration] @@ -52,7 +52,7 @@ class CreateWatchVideoService < ApplicationService watch_course_video.save! unless watch_course_video.persisted? else # 非课堂视频 - video = Video.find_by(params[:video_id]) + video = Video.find(params[:video_id]) watch_video_history = build_video_log(current_time, video.id) watch_video_history.save! end