一、进入容器
# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [x86_64-linux]
GitLab: 15.10.0-ee (defe6e7f882) EE
GitLab Shell: 14.18.0
PostgreSQL: 13.8
------------------------------------------------------------[ booted in 19.46s ]
Loading production environment (Rails 6.1.7.2)
二、修改用户密码
- 查询id为1的用户名
user = User.where(id: 1).first
- 修改密码
user.password='new_pwd'
- 确认密码
user.password_confirmation='new_pwd'
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password='new_pwd'
=> "new_pwd"
irb(main):003:0> user.password_confirmation = 'new_pwd'
=> "new_pwd"
irb(main):004:0> user.save
=> true
评论 (0)