I have been fighting with this for days now. I have created my own Registrations Controller to allow for an amdin to create and delete users. I have left the :registerable
module in my devise configuration, as I also want to users to be able to edit their profiles. I have tried taking that module out just to see if it would solve my issue. The problem that I have, is that when I create a new user as an admin, it still signs that user in, despite having my own create action. I have tried everything that I can think of to get beyond this and I am stuck.
我的登记 主计长:
class RegistrationsController < Devise::RegistrationsController
load_and_authorize_resource
def new
super
end
def create
resource.build
if resource.save
redirect_to users_path
else
clean_up_passwords(resource)
render_with_scope :new
end
end
end
申请管理员:=>注: subsequently_sign_up_path_for
在这里,检验是否可行
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = exception.message
redirect_to projects_url
end
protected
def stored_location_for(resource)
nil
end
def after_sign_in_path_for(resource)
projects_url
end
def after_sign_up_path_for(resource)
users_path
end
end
Routes File:
DeviseTest::Application.routes.draw do
devise_for :users, :controller => { :registrations => "registrations"}
devise_scope :user do
get /login => devise/sessions#new
get /logout => devise/sessions#destroy
end
resources :users, :controller => "users"
resources :projects
root :to => home#index
end
我的用户主计长负责行政工作。
class UsersController < ApplicationController
load_and_authorize_resource
# GET /users
# GET /users.xml
def index
@users = User.excludes( :id => current_user.id )
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# DELETE /users/1
# DELETE /users/1.xml
def destroy
@user = User.find(params[:id])
@user.destroy
respond_to do |format|
format.html { redirect_to(users_url) }
format.xml { head :ok }
end
end
end
Rake Lines Output:
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}
login GET /login(.:format) {:controller=>"devise/sessions", :action=>"new"}
logout GET /logout(.:format) {:controller=>"devise/sessions", :action=>"destroy"}
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
new_user GET /users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /users/:id(.:format) {:action=>"destroy", :controller=>"users"}
projects GET /projects(.:format) {:action=>"index", :controller=>"projects"}
POST /projects(.:format) {:action=>"create", :controller=>"projects"}
new_project GET /projects/new(.:format) {:action=>"new", :controller=>"projects"}
edit_project GET /projects/:id/edit(.:format) {:action=>"edit", :controller=>"projects"}
project GET /projects/:id(.:format) {:action=>"show", :controller=>"projects"}
PUT /projects/:id(.:format) {:action=>"update", :controller=>"projects"}
DELETE /projects/:id(.:format) {:action=>"destroy", :controller=>"projects"}
root /(.:format) {:controller=>"home", :action=>"index"}
所有其他工作如预期,我不能让创建的用户签署。 这不是创造用户的一个巨大问题,但如果我需要创建3或4个用户,则每一次都要签署、签署和签署一份巨大的文件。
在这方面的任何帮助都受到高度赞赏。