简体   繁体   中英

Add User from Admin with Devise in ROR

I m new to ROR, I want to add Sign-in and Sign-up in my ROR application to add users with role "Admin" and "Vendor" and for this im using Devise, which created Sign-In and Sign-up and are working fine. Now i want to create a "Add user" section from where Admin can add user having role "vendor".

As i see Devise uses

"users/sign_in" and "/users/sign_up"

actions but there is no action to add a new user. Once Admin login we cannot use "/users/sign_up" , so i created a new controller "User" which using the same "Users" modal created by Devise. When trying to save new user action always got to "/users" and so calling the Devise default controller

I m not sure how i can add new users from Admin login and keep Devise in use as well for Authentication and Authorization,

please help

If you want to create a user model, you'll need to add something like:

routes.rb

namespace :admin do
  resources :users
end

Then you crete the Admin::UsersController that creates a user model. The fact that the user will use devise to authenticate becomes immaterial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM