How I can create a CRUD (like scaffold) for Users with devise?

1.8k Views Asked by At

I just wanna that an admin can create, read, update,and delete (CRUD) normal users with the gem devise. I saw a tutorial with scaffold, but scaffold is just for CRUD, not for a login :/ I know, this question its so bad, but I not have idea

2

There are 2 best solutions below

2
Josh Brody On BEST ANSWER

Rails' generators are meant to get you up and running quickly and, by no means, are meant to replace writing code. You could create this admin-like ability easily by using http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html and then hand-writing (scary) the controller and views yourself.

But if you want to cheat, rails g scaffold_controller User email:string

0
Fabrizio Bertoglio On

Using callbacks

not generating anything, just write your code logic in the following callback, inside your model

3.1 Creating an Object

before_validation
after_validation
before_save
around_save
before_create
around_create
after_create
after_save
after_commit/after_rollback

3.2 Updating an Object

before_validation
after_validation
before_save
around_save
before_update
around_update
after_update
after_save
after_commit/after_rollback

3.3 Destroying an Object

before_destroy
around_destroy
after_destroy
after_commit/after_rollback

Generate Devise Controller

rails generate devise:controllers [scope]