已经创建过作品的用户不允许重复创建

This commit is contained in:
sw 2015-05-21 17:28:38 +08:00
parent 8c72df74d6
commit bf63ca7854
1 changed files with 8 additions and 3 deletions

View File

@ -13,9 +13,14 @@ class StudentWorkController < ApplicationController
end
def new
@stundet_work = StudentWork.new
respond_to do |format|
format.html
student_work = @homework.student_works.where("user_id = ?",User.current.id).first
if student_work.nil?
@stundet_work = StudentWork.new
respond_to do |format|
format.html
end
else
render_403
end
end