I am writing the admin area for the site; you need to enable the registration of a new account only after logging into an existing account. It was thought to completely disable registration:

routing

devise_for :users , :skip => :registerable 

model

 devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable 

But this is a bit wrong, tell me something. Thought to register before_filter :authenticate_admin! in the devise controller, but I don't know where it is located.

    1 answer 1

    Registration Devise is quite strongly sharpened for a typical case : registration being not in the system, through a public link from the login form or from another place.

    In essence, what you want is a typical create for users. Validations from Devise in the model already exist and they will work from any (even your) controller; you do not need to implement them again.

    It will be easier for you to make a separate controller with typical new and create rail tracks and one view with a form on them. And block access to the entire controller to all but admins. Devise controllers are not needed for this.

    And in the same controller, you can then place the remaining user administration tools, such as a list ( index ) and edit ( edit / update ).

    • I did as you said, but how to make rails understand that it is create and new to create devise users (admin) through my controller. Also found a way to block registration via if admin_signed_in? in registrations / new.html.erb Here are my routes : get '/admin/sign_up' => 'admins#new' devise_for :admin``root 'accounts#index' resources :accounts get '/admin' => 'admins#index', as: 'admin_root' resources :images get '/admin' => 'admins#index', as: 'admin_root' - Escobar
    • @ Escobar and why should Rails understand this? Just use the links to the forms of this controller where appropriate and disable all Devise registration tokens. - D-side
    • @Escobar I mean, you only need your User model. Just make it a typical CRUD rail controller and lock it on the admin access. In what way do you want Rails to understand you? - D-side