Devise: How to create a new user being already logged in?

后端 未结 8 2091
独厮守ぢ
独厮守ぢ 2021-02-02 16:22

I\'m going to create a multi user app, so, I will have a admin user that will have permission to create new ones.

I\'ve created the UsersControllerbut when

相关标签:
8条回答
  • 2021-02-02 16:43

    In a controller method can't you just go:

    def create_user
        @user = User.new(:email => params[:email], :password => params[:password])
        @user.save
        ...
    end
    
    0 讨论(0)
  • 2021-02-02 16:50

    I added in the Registrations Controller:

    class RegistrationsController < Devise::RegistrationsController
        ...
        skip_before_action :require_no_authentication, only: [:new, :create]
        ...
    end
    

    And it worked for me. I can now go and create a new user.

    0 讨论(0)
提交回复
热议问题