This post covers how to manage
Admin models in Devise, including apply roles to
Admin and restrict registration of
Admin from public access.
gem 'devise' to Gemfile and initialize Devise with
rails generate devise:install.
Generate customizable views for
Now we will customize RegistrationsController to disable public access.
Change route to use customized controller:
Users could have different roles. Assume we know the set of roles for administrators, we can add a
role column to
Edit the migration just created, set
Admins model, we will add an enum attribute
Now we have a handful of helpers associated, for example:
Based on roles, we could restrict
Admin registration to
After Sign In
To redirect users to a specific page on successful sign in/out, add this to