Skip to content

Instantly share code, notes, and snippets.

@lpsm-dev
Created October 6, 2022 20:02
Show Gist options
  • Save lpsm-dev/b209e3bd8f2e6f08742ed23663f7f367 to your computer and use it in GitHub Desktop.
Save lpsm-dev/b209e3bd8f2e6f08742ed23663f7f367 to your computer and use it in GitHub Desktop.
[GitLab] - Create Admin user in Rails Console
user = User.new(username: 'user', email: '[email protected]', name: 'user', password: 'user', password_confirmation: 'user')
# Use it only if you wish user to be automatically confirmed. If skipped, user receives confirmation e-mail
user.skip_confirmation!
user.admin = true
user.save!
@Hi-Angel
Copy link

Pls update the gist, the current way is:

u = User.new(username: 'test_user', email: '[email protected]', name: 'Test User', password: 'password', password_confirmation: 'password')
u.assign_personal_namespace(Organizations::Organization.default_organization)
u.skip_confirmation! # Use only if you want the user to be automatically confirmed. If you do not use this, the user receives a confirmation email.
u.admin = true # Use only if you want user to be admin
u.save!

@lpsm-dev
Copy link
Author

Thanks @Hi-Angel! I will try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment