parent
529cf4f4f8
commit
de201ae8f6
@ -0,0 +1,3 @@
|
||||
class CourseInfos < ActiveRecord::Base
|
||||
attr_accessible :typeId, :typeName
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
class CreateCourseInfos < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :course_infos do |t|
|
||||
t.integer :course_id
|
||||
t.integer :user_id
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
#迁移课程管理员数据
|
||||
Project.all.each do |project|
|
||||
if project.project_type == 1
|
||||
course = Course.find_by_extra(project.identifier)
|
||||
if course
|
||||
projectinfos = ProjectInfo.find_all_by_project_id(project.id)
|
||||
projectinfos.each do |projinfo|
|
||||
courseinfo = CourseInfos.new
|
||||
courseinfo.course_id = course.id
|
||||
courseinfo.user_id = projinfo.user_id
|
||||
courseinfo.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
typeId: 1
|
||||
typeName: MyString
|
||||
|
||||
two:
|
||||
typeId: 1
|
||||
typeName: MyString
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CourseInfosTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in new issue