From a29ab60481a788aaa1fb6ae9413bf760fed07980 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 10 Sep 2015 11:34:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=81=E5=B8=88=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E8=83=BD=E6=98=BE=E7=A4=BA=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- app/controllers/users_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 593d6bf53..018a293e3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -631,7 +631,7 @@ class StudentWorkController < ApplicationController unless @homework.save logger.debug @homework.errors.full_messages else - student_work = @homework.student_works.where(user_id: User.current.id).first + student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first end end student_work diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9b2d49f2d..d71b24fc8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -354,7 +354,7 @@ class UsersController < ApplicationController @user = User.current @homework = HomeworkCommon.find(params[:homework_id]) @is_test = params[:is_test] == 'true' - @student_work = @homework.student_works.where(user_id: User.current.id).first + @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first if @student_work.nil? @student_work = StudentWork.new end @@ -369,7 +369,7 @@ class UsersController < ApplicationController def user_commit_homework homework = HomeworkCommon.find(params[:homework]) - student_work = homework.student_works.where(user_id: User.current.id).first + student_work = StudentWork.where(homework_common_id: homework.id, user_id: User.current.id).first if student_work student_work.save flash[:notice] = l(:notice_successful_create)