2014-07-09 16:02:15 +08:00
|
|
|
# -*coding:utf-8 -*-
|
2014-07-08 18:02:10 +08:00
|
|
|
class AddAuthority < ActiveRecord::Migration
|
|
|
|
def change
|
|
|
|
# 添加课程权限
|
|
|
|
Role.all.each do |role|
|
|
|
|
if role.name == '学生'
|
|
|
|
role.permissions.append(:paret_in_homework)
|
2014-07-09 16:02:15 +08:00
|
|
|
role.permissions.append(:as_student)
|
2014-07-08 18:02:10 +08:00
|
|
|
elsif role.name == 'Manager'
|
|
|
|
role.permissions.append(:is_manager)
|
2014-07-09 16:02:15 +08:00
|
|
|
role.permissions.append(:as_teacher)
|
|
|
|
elsif role.name == '助教'
|
|
|
|
role.permissions.append(:as_teacher)
|
|
|
|
elsif role.name == '老师'
|
|
|
|
role.permissions.append(:as_teacher)
|
2014-07-08 18:02:10 +08:00
|
|
|
end
|
|
|
|
role.save(:validate => false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|