task to make a user an admin. Alter migration to make admins users with old role of Admin or Organizer

This commit is contained in:
Stella Rouzi 2014-09-04 15:53:47 +03:00
parent 9ff8becaf6
commit 760bca6ff0
2 changed files with 19 additions and 1 deletions

View file

@ -8,6 +8,7 @@ class MigrateRolesForCancancan < ActiveRecord::Migration
Conference.all.each do |conference|
if role.name == 'Admin' || role.name == 'Organizer'
user.add_role :organizer, conference
user.update_columns(is_admin: true)
else
user.add_role role.name.parameterize.underscore.to_sym, conference
end
@ -22,6 +23,6 @@ class MigrateRolesForCancancan < ActiveRecord::Migration
end
def down
raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration. Deleted events cannot be re-created')
raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration.')
end
end