simonlehmann
simonlehmann

Reputation: 882

CRUD actions on a Devise User model - Rails 5

I'm working on a project that has a User Devise model and an Admin Devise model, and I want an Admin to be able to perform CRUD on the User model.

I've set up both Devise models following the Devise Wiki's How to Setup Multiple Devise User Models guide (including step 4 - exposing the scoped controllers).

This has given me the Devise views and controllers for confirmations, passwords, registrations, sessions and unlocks, but no users_controller to add CRUD actions to.

Could I simply create a users_controller and make sure it uses the correct users table in the database, or should I add CRUD actions to the registrations_controller?

Is the above advisable, or is there a more elegant way of setting up a CRUD interface for an Admin to be able to manage the User model?

Any help would be much appreciated.

Upvotes: 0

Views: 283

Answers (1)

Vasilisa
Vasilisa

Reputation: 4640

Devise works only with sign_up/sign_in process. It assumes not only simple user creation, but some more things, like email sending. So if you want to create/update/destroy users you need to create separate UsersController. It is better to add an admin namespace to it

Upvotes: 1

Related Questions