-
Notifications
You must be signed in to change notification settings - Fork 11
Create First Admin
E. Lynette Rayle edited this page May 3, 2022
·
1 revision
NOTE: All example run in rails console
unless otherwise noted.
Role.all
If the result includes something like...
=> [#<Role:0x00007fb0b7e5d480 id: 1, name: "admin">]
... then the admin role already exists. OTHERWISE, create the admin role.
admin_role = Role.find(1)
Substitute the actual "admin" id for 1
from the list of roles.
admin_role = Role.new(name: 'admin')
user = User.find_by(email: "[email protected]")
user.roles << admin_role
Verify the role was added...
user.roles
=> [#<Role:0x00007fb0b76fd690 id: 1, name: "admin">]