# How do I activate a user account via console?

**URL:** <https://meta.discourse.org/t/how-do-i-activate-a-user-account-via-console/286191>\
**Category:** Development\
**Tags:** rails-console\
**Created:** [November 21, 2023, 11:47am UTC](https://meta.discourse.org/t/how-do-i-activate-a-user-account-via-console/286191 "2023-11-21T11:47:40Z")\
**Posts on this page:** 3\
**Page:** 1

## AI-generated summary

In a discussion about activating a user account via the Rails console, [meglio](/t/-/286191/1) asks for the correct commands, noting that older methods are no longer effective. [Arkshine](/t/-/286191/2) responds that while there is no single direct command, the task can be accomplished by entering the Rails console and running a specific query. The suggested process involves navigating to the Discourse directory and entering the app container using `cd /var/discourse` and `./launcher enter app`, followed by starting the console with `rail c`. Once inside, the user can activate the account by finding the user by username and calling the activate method: `User.find_by(username: "username_to_activate").activate`. After execution, the user can exit the console by typing `exit` twice. [Arkshine](/t/-/286191/2) confirms the action's success by noting it will appear in the system logs.

<div class="post-metadata">

**Author:** ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)\
**Post date:** [November 21, 2023, 11:47am UTC](https://meta.discourse.org/t/how-do-i-activate-a-user-account-via-console/286191/1 "2023-11-21T11:47:40Z")

</div>

I need to activate a user via console so that they do not have to click on the activation link in an email. What would be the commands in console to do so?

Old methods found in older topics do not seem to work anymore.

---

<div class="post-metadata">

**Author:** ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
**Post date:** [November 21, 2023, 2:15pm UTC](https://meta.discourse.org/t/how-do-i-activate-a-user-account-via-console/286191/2 "2023-11-21T14:15:46Z")

</div>

I don’t think there is a direct command for that, but you can use the Rails console.  
First, you enter into it:

```plaintext
cd /var/discourse
./launcher enter app
rail c

```

Then, you find the user by its username (replace `username_to_activate`) and activate it.

```plaintext
User.find_by(username: "username_to_activate").activate

```

You can type `exit` two times to quit.

You should see that action in the log:

![image](https://global.discourse-cdn.com/meta/optimized/4X/3/a/b/3ab79ddfa130e0673f159c898316d17938861c96_2_690x43.png)

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [December 21, 2023, 2:16pm UTC](https://meta.discourse.org/t/how-do-i-activate-a-user-account-via-console/286191/3 "2023-12-21T14:16:34Z")

</div>

Closed on December 21, 2023, 2:16pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
