如何通过SSH控制台激活Discourse管理员账户?终端操作遇阻求助
Hey there, let's tackle that stuck terminal issue first! When you run user = User.find_by_email("<admin_email>") and see the (END) prompt, that's because your terminal is using a pager (like less) to display the lengthy user details output.
To get back to the Rails console prompt ([1] pry (main) >), just press the q key on your keyboard. That will exit the pager view and let you continue typing commands normally.
Once you're back at the console prompt, run these commands one by one to activate and configure your admin account:
# Mark the user as an admin user.admin = true # Approve the user account user.approved = true # Save these changes to the database user.save # Confirm the email token to skip email verification EmailToken.confirm(user.email_tokens.first.token)
After running user.save, you should see output like => true—that means your changes were saved successfully. The final command will validate the email token, so you won't need to wait for the verification email anymore.
Once all commands are done, you can exit the Rails console by typing exit and pressing enter, then exit the app container with another exit command. After that, you should be able to log in directly as the admin.
内容的提问来源于stack exchange,提问作者G Pritiranjan Das

