Hi there,
I’m using Devise and CanCan.
All my users will be created and manage through my
Admin::UsersController by a User that has a Role of “Admin”. Devise
will not register or unregister a User.
Every time that a log_in “Admin” User, that was authenticated
( before_filter :authenticate_user! ), try to delete other user Devise
drives me to sing_in page.
What should I do to let the “Admin” User delete others?
David S.
Codes:
class Admin::UsersController < Admin::AdminController
before_filter :authenticate_user!
load_and_authorize_resource
DELETE /admin/users/:id HTML
#----------------------------------------------------------------------------
def destroy
#@user = User.find(params[:id])
respond_to do |format|
if @user.destroy
format.html { redirect_to(admin_users_url, :notice => ‘User
was successfully destroyed.’ ) }
format.xml { head :ok }
else
format.html { redirect_to(admin_users_url, :notice => ‘User
was NOT successfully destroyed.’ ) }
format.xml { head :ok } #FIXME colocar de forma a mostrar que
não deu certo.
end
end
end
end