class AddPermissionsToEducodeSalesPermissions < ActiveRecord::Migration[5.2] def change last_position = EducodeSales::Permission.all.order(position: :asc).last.position EducodeSales::Permission.create(name: '查看方案', subject: 'Idea', action: 'read', clazz: 'idea', position: last_position + 1) EducodeSales::Permission.create(name: '添加方案', subject: 'Idea', action: 'create', clazz: 'idea', position: last_position + 2) EducodeSales::Permission.create(name: '编辑方案', subject: 'Idea', action: 'update', clazz: 'idea', position: last_position + 3) EducodeSales::Permission.create(name: '移除方案', subject: 'Idea', action: 'destroy', clazz: 'idea', position: last_position + 4) EducodeSales::Permission.create(name: '恢复方案', subject: 'Idea', action: 'recycle', clazz: 'idea', position: last_position + 5) EducodeSales::Permission.create(name: '查看历史记录', subject: 'Idea', action: 'read_history', clazz: 'idea', position: last_position + 6) end end