The second way works. So we'll go with that.

This commit is contained in:
Jez Caudle 2024-05-14 20:08:36 +01:00
parent be035f9e31
commit 8f9145ba54
2 changed files with 5 additions and 18 deletions

View File

@ -1,17 +0,0 @@
class RegistrationsController < Devise::RegistrationsController
before_action :one_user_registered, only: [:new, :create]
protected
def one_user_registered
if User.count == 1
if user_signed_in?
redirect_to root_path
else
redirect_to new_user_session_path
end
end
end
end

View File

@ -5,7 +5,11 @@ Rails.application.routes.draw do
resources :virtuals, only: [ :new, :create, :edit, :update, :destroy]
end
devise_for :users, controllers: { registrations: "registrations" }
devise_for :users, :skip => [:registrations]
as :user do
get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'
put 'users' => 'devise/registrations#update', :as => 'user_registration'
end
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html