Skip to content

Commit

Permalink
GPT4, I want to make new sign up user as admin if such user is the fi…
Browse files Browse the repository at this point in the history
…rst user, how to modify the code?
  • Loading branch information
Eric-Guo committed Nov 9, 2023
1 parent 9c2e4ba commit 6061b85
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/user/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
class User::RegistrationsController < Devise::RegistrationsController
layout 'sessions', only: %i[new create]

def create
super do |user|
if User.count == 1
user.admin = true
user.save
user.confirm
end
end
end

private

def sign_up_params
Expand Down

0 comments on commit 6061b85

Please sign in to comment.