diff --git a/db/migrate/20150120140346_refactor_roles.rb b/db/migrate/20150120140346_refactor_roles.rb index f8c8606de..192a6b710 100644 --- a/db/migrate/20150120140346_refactor_roles.rb +++ b/db/migrate/20150120140346_refactor_roles.rb @@ -3,8 +3,11 @@ class RefactorRoles < ActiveRecord::Migration add_column :users, :roles, :string, array: true User.all.each do |x| - x.roles = [x.role.code] - x.save + c = x.role.try(:code) + if c + x.roles = [c] + x.save + end end remove_column :users, :role_id