新建课程的教师团队为空
This commit is contained in:
parent
b805fdc666
commit
3b8dded2bc
|
@ -33,6 +33,8 @@ class SyllabusesController < ApplicationController
|
|||
@syllabus.user_id = User.current.id
|
||||
@syllabus.description = Message.where("id = 19412").first.nil? ? '' : Message.where("id = 19412").first.content
|
||||
if @syllabus && @syllabus.save
|
||||
member = SyllabusMember.create(:user_id => @syllabus.user_id, :rank => 1)
|
||||
@syllabus.syllabus_members << member
|
||||
respond_to do |format|
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
format.html {redirect_to syllabus_path(@syllabus)}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class AddSyllabusMembers < ActiveRecord::Migration
|
||||
def up
|
||||
Syllabus.all.each do |syllabus|
|
||||
if syllabus.syllabus_members.empty?
|
||||
member = SyllabusMember.create(:user_id => syllabus.user_id, :rank => 1)
|
||||
syllabus.syllabus_members << member
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue