21 lines
607 B
Ruby
21 lines
607 B
Ruby
# -*coding:utf-8 -*-
|
|
class AddAuthority < ActiveRecord::Migration
|
|
def change
|
|
# 添加课程权限
|
|
Role.all.each do |role|
|
|
if role.name == '学生'
|
|
role.permissions.append(:paret_in_homework)
|
|
role.permissions.append(:as_student)
|
|
elsif role.name == 'Manager'
|
|
role.permissions.append(:is_manager)
|
|
role.permissions.append(:as_teacher)
|
|
elsif role.name == '助教'
|
|
role.permissions.append(:as_teacher)
|
|
elsif role.name == '老师'
|
|
role.permissions.append(:as_teacher)
|
|
end
|
|
role.save(:validate => false)
|
|
end
|
|
end
|
|
end
|