I have installed Devise and created Users and also Admins using Option 1 from this tutorial https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-role
No
I highly recommend using the Single Table Inheritance (STI). You could do the STI by adding a column named type
with a string
datatype in the users
table and create an admin
model as well as a normal_user
model both models will inherit from the user
model of the devise
gem.
class NormalUser < User
end
class Admin < User
end
The type column is a reserved word which will hold a value either NormalUser
or Admin
according to the user type you created.
To create an admin use Admin.create(...)
and to create a normal user use NormalUser.create(...)
where the dots are the attributes of the Admin
and the NormalUser