开发者

Devise: How to create a private admin role?

开发者 https://www.devze.com 2023-01-21 14:36 出处:网络
I have a simple Rails 3 blog app that needs an admin开发者_运维百科 user so I can restrict creating and editing blog entries to the admin. I\'ve used devise before, but only for users that are public

I have a simple Rails 3 blog app that needs an admin开发者_运维百科 user so I can restrict creating and editing blog entries to the admin. I've used devise before, but only for users that are public and can be created by anyone. I don't want the ability to create an admin to be publicly accessible. How should I configure devise to be able to have an admin user?

Update:

After creating an Admin model, you might want to know how to create an admin that can log in (since you won't be able to register them on the front-end).


Have a look at the HOWTO in Github. There are basically two options:

  1. Create a separate admin model
  2. Add a admin attribute to the existing user model

I personally prefer option 1 for larger applications which tend to have different views for admins and normal users. For smaller apps I would recommend option 2.

0

精彩评论

暂无评论...
验证码 换一张
取 消