views:

130

answers:

2

I have implemented Devise in a Rails 3 application and I need admin users to be able to manage users. Users are not registerable and therefore an admin must create accounts. What would be the best way to go about this?

It doesn't seem very DRY to create my own UsersController when Devise already provides Devise::RegistrationController but I don't see any other options.

A: 

You can override the RegistrationController to provide the functionality you need. Check the first answer from here: http://stackoverflow.com/questions/3546289/override-devise-registrations-controller

pushmatrix
Haven't tested this, but you could override the RegistrationController and simply put a before_filter in it that ensures that an admin is making the request.
pushmatrix
I actually have my own registration controller right now for authorization. My problem is that when calling sign_up as another user you are instantly logged in as that user (like it's a user registration). If I'm going to be creating all of my own methods anyway I think I'd rather just have my own UsersController
jcm
A: 

I opted to create my own UsersController along side the RegistrationController. It really makes sense to have my own RESTful controller admin purposes. It is not devise's job to manage user records and maintain administrative fields associated with them. It is, after all, an authentication framework. It just seems correct to leave it to do what it is designed for. You are required to create your own user model for a reason.

jcm