I'm using devise in my Ruby on Rails project and users have an admin-attribute:
schema.rb:
create_table "users", force: :cascade do |t|
.
t.boolean "admin", default: false
end
I want, that an admin user can edit other users. I'm not the first one asking this question, but all the given answers lack clear instructions:
- There is an entry in the devise wiki from 2011: https://github.com/plataformatec/devise/wiki/How-To%3a-Manage-users-through-a-CRUD-interface
But I don't understand what I need to do: It mentions "devise_for :users, :path_prefix => 'my'"
in the routes, but I don't have that in my routes. Then, it mentions, how I need to remove the password key of the params hash, but my users_controller is empty. No more instructions are provided.
- There is a stackoverflow answer to this: Devise: Allow admins to edit other users - Rails
But I don't fully understand, what needs to be done: I see, that I need to add devise_for :users, :path_prefix => 'd'
to my routes, but the poster talks also about building out your forms and controller on your own, and isolating the Userscontroller. I don't understand, what he means.
- There is another stackoverflow answer: Rails, Devise - Admin trying to edit another user profile, own profile loaded instead
In this one, the poster uses cancan and it seems, he does have an admin class in his usercontroller, which I don't have:
class Admin::UsersController < ApplicationController
def index
@users = User.all
end
end
Once again, I don't know, how the poster got there and what he did.
Is there a step-by-step guide, to let the admin-user edit other userprofiles?
You can access my code here: https://github.com/Metaphysiker/philosophica
Thanks in advance!