# \#rails-console

**URL:** https://meta.discourse.org/tag/rails-console/466.md

[Latest](https://meta.discourse.org/latest.md) · [Categories](https://meta.discourse.org/categories.md) · [Tags](https://meta.discourse.org/tags.md)

---

## [Using Hidden Site Settings](https://meta.discourse.org/t/using-hidden-site-settings/308773)

<div class="topic-metadata">

**Author:** [@Discourse](https://meta.discourse.org/u/Discourse)\
**Replies:** 0\
**Last updated:** [May 20, 2024, 10:51pm UTC](https://meta.discourse.org/t/using-hidden-site-settings/308773 "2024-05-20T22:51:56Z")

</div>

:bookmark: This is a how-to guide about Hidden Site Settings, how to enable them, and why you might want to adjust them. :person\_raising\_hand: Required user level: Administrator :warning: Important: Console access is …

---

## [Hidden Site Settings Reference Guide](https://meta.discourse.org/t/hidden-site-settings-reference-guide/308774)

<div class="topic-metadata">

**Author:** [@Discourse](https://meta.discourse.org/u/Discourse)\
**Replies:** 0\
**Last updated:** [May 20, 2024, 10:55pm UTC](https://meta.discourse.org/t/hidden-site-settings-reference-guide/308774 "2024-05-20T22:55:23Z")

</div>

:bookmark: This is a reference guide for describing all available Hidden Site Settings. :person\_raising\_hand: Required user level: Administrator Hidden site settings in Discourse are advanced configuration options th…

---

## [Change staff email address from console](https://meta.discourse.org/t/change-staff-email-address-from-console/42062)

<div class="topic-metadata">

**Author:** [@Discourse](https://meta.discourse.org/u/Discourse)\
**Replies:** 1\
**Last updated:** [February 23, 2026, 3:30am UTC](https://meta.discourse.org/t/change-staff-email-address-from-console/42062 "2026-02-23T03:30:15Z")

</div>

:bookmark: This guide describes how to change a staff member’s email address from the console using the Rails console. It applies to situations where an administrator needs to update an email without confirmation from t…

---

## [Bulk convert topics from a Category to Group PMs](https://meta.discourse.org/t/bulk-convert-topics-from-a-category-to-group-pms/218811)

<div class="topic-metadata">

**Author:** [@nathank](https://meta.discourse.org/u/nathank)\
**Replies:** 3\
**Last updated:** [December 22, 2025, 12:54pm UTC](https://meta.discourse.org/t/bulk-convert-topics-from-a-category-to-group-pms/218811 "2025-12-22T12:54:21Z")

</div>

I plan to convert a bunch of topics to group PMs in order to depreciate some barely used categories. We can’t do that via the UI (only one by one), nor can I find a bulk way to do it. As far as I can tell this should wo…

---

## [Unable to Bulk Suspend/Deactivate Users in Rails Console on Discourse 3.5.0.beta5-dev](https://meta.discourse.org/t/unable-to-bulk-suspend-deactivate-users-in-rails-console-on-discourse-3-5-0-beta5-dev/367571)

<div class="topic-metadata">

**Author:** [@thaidb](https://meta.discourse.org/u/thaidb)\
**Replies:** 1\
**Last updated:** [May 28, 2025, 2:30pm UTC](https://meta.discourse.org/t/unable-to-bulk-suspend-deactivate-users-in-rails-console-on-discourse-3-5-0-beta5-dev/367571 "2025-05-28T14:30:25Z")

</div>

Hi everyone, I’m facing a persistent issue trying to bulk suspend/deactivate users on my Discourse instance (version 3.5.0.beta5-dev) via the Rails console. I’m trying to exclude my admin account (hoangthai, user ID 100)…

---

## [Undo an Official Warning](https://meta.discourse.org/t/undo-an-official-warning/103655)

<div class="topic-metadata">

**Author:** [@Discourse](https://meta.discourse.org/u/Discourse)\
**Replies:** 8\
**Last updated:** [January 30, 2025, 7:06pm UTC](https://meta.discourse.org/t/undo-an-official-warning/103655 "2025-01-30T19:06:17Z")

</div>

:bookmark: This guide explains how to remove an official warning in Discourse via the console, particularly aimed at self-hosting users. :person\_raising\_hand: Required user level: System Administrator …

---

## [Allow email in for moderators, staff, and admins](https://meta.discourse.org/t/allow-email-in-for-moderators-staff-and-admins/212147)

<div class="topic-metadata">

**Author:** [@nathank](https://meta.discourse.org/u/nathank)\
**Replies:** 11\
**Last updated:** [August 12, 2023, 12:53am UTC](https://meta.discourse.org/t/allow-email-in-for-moderators-staff-and-admins/212147 "2023-08-12T00:53:10Z")

</div>

The option “Custom incoming email address” is not available for automatic groups. That is fine for everyone and the trust\_level groups, but I’m not sure it makes sense for staff/admins/moderators. I’ve had to make a sep…

---

## [How to change a poll while it is live (without losing the data)](https://meta.discourse.org/t/how-to-change-a-poll-while-it-is-live-without-losing-the-data/251986)

<div class="topic-metadata">

**Author:** [@nathank](https://meta.discourse.org/u/nathank)\
**Replies:** 5\
**Last updated:** [October 8, 2024, 10:05pm UTC](https://meta.discourse.org/t/how-to-change-a-poll-while-it-is-live-without-losing-the-data/251986 "2024-10-08T22:05:02Z")

</div>

I’ve found that when my users start with polls, they make all kinds of errors which often aren’t realised until the poll is well underway. Unfortunately, any edits to a poll cause the poll data to be wiped. This is unde…

---

## [Marking multiple account as Suspended account](https://meta.discourse.org/t/marking-multiple-account-as-suspended-account/320525)

<div class="topic-metadata">

**Author:** [@Jaskaran](https://meta.discourse.org/u/Jaskaran)\
**Replies:** 5\
**Last updated:** [August 7, 2024, 3:40pm UTC](https://meta.discourse.org/t/marking-multiple-account-as-suspended-account/320525 "2024-08-07T15:40:46Z")

</div>

When a user is marked as suspended from the UI, the backend updates the suspended\_at and suspended\_till fields in the user table. I have 500 users whose profiles need to be marked as suspended. I’m planning to retrieve t…

---

## [User attributes](https://meta.discourse.org/t/user-attributes/315619)

<div class="topic-metadata">

**Author:** [@anon82911141](https://meta.discourse.org/u/anon82911141)\
**Replies:** 7\
**Last updated:** [July 11, 2024, 6:23pm UTC](https://meta.discourse.org/t/user-attributes/315619 "2024-07-11T18:23:15Z")

</div>

Hi, I tried running commands in rails c such as User.find(1).update(ip\_address: nil, topics\_viewed: nil) to update the things in this list below - however, I kept getting errors: How would I change these values? Th…

---

## [Completely remove user data from the system](https://meta.discourse.org/t/completely-remove-user-data-from-the-system/310629)

<div class="topic-metadata">

**Author:** [@Crius](https://meta.discourse.org/u/Crius)\
**Replies:** 7\
**Last updated:** [June 18, 2024, 1:09pm UTC](https://meta.discourse.org/t/completely-remove-user-data-from-the-system/310629 "2024-06-18T13:09:34Z")

</div>

Hey, so we might have a situation in which we want to completely erase every trace of a user from the database. I won’t go into details as it’s sensitive but also due to GDPR we might have to prove that we don’t hold any…

---

## [Removing specific staff action logs using the console](https://meta.discourse.org/t/removing-specific-staff-action-logs-using-the-console/312393)

<div class="topic-metadata">

**Author:** [@Isambard](https://meta.discourse.org/u/Isambard)\
**Replies:** 4\
**Last updated:** [June 17, 2024, 5:17pm UTC](https://meta.discourse.org/t/removing-specific-staff-action-logs-using-the-console/312393 "2024-06-17T17:17:47Z")

</div>

Continued from: Don't log all post edits in staff action logs for a user-merge - #4 by JammyDodger Thanks. In the interim, if a rails console guru can suggest a command to delete system post edit logs for a specified da…

---

## [Rebake all posts matching a pattern](https://meta.discourse.org/t/rebake-all-posts-matching-a-pattern/48713)

<div class="topic-metadata">

**Author:** [@Discourse](https://meta.discourse.org/u/Discourse)\
**Replies:** 1\
**Last updated:** [May 30, 2024, 11:18pm UTC](https://meta.discourse.org/t/rebake-all-posts-matching-a-pattern/48713 "2024-05-30T23:18:42Z")

</div>

:bookmark: This guide provides instructions on how to rebake all posts in Discourse that match a specific string or regular expression, utilizing the Rails console for additional advanced options. :person\_raising\_hand: …

---

## [Help with Rails console to edit text template](https://meta.discourse.org/t/help-with-rails-console-to-edit-text-template/308691)

<div class="topic-metadata">

**Author:** [@nordize](https://meta.discourse.org/u/nordize)\
**Replies:** 7\
**Last updated:** [May 30, 2024, 2:08am UTC](https://meta.discourse.org/t/help-with-rails-console-to-edit-text-template/308691 "2024-05-30T02:08:19Z")

</div>

I’d like to edit directly in rails a text template, say user\_notifications.user\_watching\_first\_post.text\_body\_template. Can someone please help point me to the rails console commands for this? I’m not rails savvy and co…

---

## [Restore (undelete) all posts by a user](https://meta.discourse.org/t/restore-undelete-all-posts-by-a-user/304643)

<div class="topic-metadata">

**Author:** [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Replies:** 0\
**Last updated:** [April 19, 2024, 4:50pm UTC](https://meta.discourse.org/t/restore-undelete-all-posts-by-a-user/304643 "2024-04-19T16:50:12Z")

</div>

If you want to restore/undelete all deleted posts by a user, you can do this: u=User.find\_by\_username('=username='); moderator=User.find\_by\_username('=moderator='); deleted\_posts = Post.with\_deleted.where(user\_id: u…

---

## [Change pie to bar in active poll](https://meta.discourse.org/t/change-pie-to-bar-in-active-poll/302712)

<div class="topic-metadata">

**Author:** [@Roi](https://meta.discourse.org/u/Roi)\
**Replies:** 4\
**Last updated:** [April 14, 2024, 9:56am UTC](https://meta.discourse.org/t/change-pie-to-bar-in-active-poll/302712 "2024-04-14T09:56:17Z")

</div>

Hi all, is it possible to change from pie to bar in an active poll? I created a poll and then edited the post and changed from pie to bar, as I do not see the participants in the pie version of the poll, although they s…

---

## [Rails console commands](https://meta.discourse.org/t/rails-console-commands/300682)

<div class="topic-metadata">

**Author:** [@Isambard](https://meta.discourse.org/u/Isambard)\
**Replies:** 13\
**Last updated:** [March 25, 2024, 1:19pm UTC](https://meta.discourse.org/t/rails-console-commands/300682 "2024-03-25T13:19:21Z")

</div>

I found the rails console and learned that you can do blackmagic such as: DB.exec(\<\<~SQL) UPDATE topics SET title = 'psql redo!' WHERE id = 886 SQL How do I find out what commands/functions can be executed in the…

---

## [How to change topic date after import](https://meta.discourse.org/t/how-to-change-topic-date-after-import/292565)

<div class="topic-metadata">

**Author:** [@Ventrilo](https://meta.discourse.org/u/Ventrilo)\
**Replies:** 11\
**Last updated:** [February 9, 2024, 1:13am UTC](https://meta.discourse.org/t/how-to-change-topic-date-after-import/292565 "2024-02-09T01:13:31Z")

</div>

I imported all my content, but I want the topic date of each new topic to change as if it was posted from today’s date, there is no additional posts per topic

---

## [Unable to start discourse from source while running "bin/ember-cli -u"](https://meta.discourse.org/t/unable-to-start-discourse-from-source-while-running-bin-ember-cli-u/290967)

<div class="topic-metadata">

**Author:** [@Ilamathi\_Natarajan](https://meta.discourse.org/u/Ilamathi_Natarajan)\
**Replies:** 3\
**Last updated:** [February 4, 2024, 10:39pm UTC](https://meta.discourse.org/t/unable-to-start-discourse-from-source-while-running-bin-ember-cli-u/290967 "2024-02-04T22:39:56Z")

</div>

I am trying to install Discourse on Ubuntu, and while running bin/ember-cli -u, the following errors are occurring, warning Resolution field "unset-value@2.0.1" is incompatible with requested version "unset-value@^1.0.0…

---

## [How do I activate a user account via console?](https://meta.discourse.org/t/how-do-i-activate-a-user-account-via-console/286191)

<div class="topic-metadata">

**Author:** [@meglio](https://meta.discourse.org/u/meglio)\
**Replies:** 1\
**Last updated:** [November 21, 2023, 2:15pm UTC](https://meta.discourse.org/t/how-do-i-activate-a-user-account-via-console/286191 "2023-11-21T14:15:46Z")

</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.

---

## [Group-specific Sidebar Categories/Tags](https://meta.discourse.org/t/group-specific-sidebar-categories-tags/250437)

<div class="topic-metadata">

**Author:** [@diabolicvincent](https://meta.discourse.org/u/diabolicvincent)\
**Replies:** 3\
**Last updated:** [November 16, 2023, 11:50am UTC](https://meta.discourse.org/t/group-specific-sidebar-categories-tags/250437 "2023-11-16T11:50:38Z")

</div>

One should be able to add certain categories/tags to the sidebar for specific groups. E.g. this would allow all members of a group to access their group category quickly without every group member having to set that up t…

---

## [How to reset the new user tips for everyone?](https://meta.discourse.org/t/how-to-reset-the-new-user-tips-for-everyone/283094)

<div class="topic-metadata">

**Author:** [@thoka](https://meta.discourse.org/u/thoka)\
**Replies:** 4\
**Last updated:** [July 18, 2023, 7:21pm UTC](https://meta.discourse.org/t/how-to-reset-the-new-user-tips-for-everyone/283094 "2023-07-18T19:21:49Z")

</div>

Would love to learn, how to enable this for all users via command line. Most of them will love it.

---

## [How do I avoid rate limiting when importing a bunch of data?](https://meta.discourse.org/t/how-do-i-avoid-rate-limiting-when-importing-a-bunch-of-data/270449)

<div class="topic-metadata">

**Author:** [@Chris\_Dawson](https://meta.discourse.org/u/Chris_Dawson)\
**Replies:** 13\
**Last updated:** [July 6, 2023, 12:07am UTC](https://meta.discourse.org/t/how-do-i-avoid-rate-limiting-when-importing-a-bunch-of-data/270449 "2023-07-06T00:07:12Z")

</div>

I am trying to create a bunch of topics + posts automatically. However, I keep getting hit by rate limits. I first tried this using the API. My script quickly hit 429 errors. I tried adjusting the rate limits as the adm…

---

## [Renaming tags in the rails console](https://meta.discourse.org/t/renaming-tags-in-the-rails-console/267375)

<div class="topic-metadata">

**Author:** [@Campano](https://meta.discourse.org/u/Campano)\
**Replies:** 12\
**Last updated:** [June 17, 2023, 8:55am UTC](https://meta.discourse.org/t/renaming-tags-in-the-rails-console/267375 "2023-06-17T08:55:30Z")

</div>

Continuing the discussion from Can’t fix tag names with dots/periods: Hello, Can anyone provide a tested guide on how to rename tags in the rails console? I have no experience using the rails console and don’t want to…

---

## [Want to modify rails code of discourse application](https://meta.discourse.org/t/want-to-modify-rails-code-of-discourse-application/250544)

<div class="topic-metadata">

**Author:** [@kapil65](https://meta.discourse.org/u/kapil65)\
**Replies:** 1\
**Last updated:** [January 3, 2023, 10:40am UTC](https://meta.discourse.org/t/want-to-modify-rails-code-of-discourse-application/250544 "2023-01-03T10:40:03Z")

</div>

I want to modified the code of discourse from backend and change scope of some model but it will not reflect on UI, how can I modify the backend code of discourse application. Like I want to change the scope of some mod…

---

## [Ruby multi-CPU threading](https://meta.discourse.org/t/ruby-multi-cpu-threading/248433)

<div class="topic-metadata">

**Author:** [@rahim123](https://meta.discourse.org/u/rahim123)\
**Replies:** 14\
**Last updated:** [December 20, 2022, 10:46pm UTC](https://meta.discourse.org/t/ruby-multi-cpu-threading/248433 "2022-12-20T22:46:19Z")

</div>

Hi there, as I’ve mention in previous posts, I’m doing test runs of my Drupal → Discourse migration to have all the solutions in place before I ultimately take down the old site to migrate the production data with its ~2…

---

## [Rebake and Oneboxes confusion](https://meta.discourse.org/t/rebake-and-oneboxes-confusion/248167)

<div class="topic-metadata">

**Author:** [@rahim123](https://meta.discourse.org/u/rahim123)\
**Replies:** 2\
**Last updated:** [December 12, 2022, 1:57am UTC](https://meta.discourse.org/t/rebake-and-oneboxes-confusion/248167 "2022-12-12T01:57:18Z")

</div>

Hi there, on my testbed migration from Drupal I ran a bunch of regexp\_replace commands from the Postegres console, requiring a rebake of all the posts. So for the past \>12 hours I have rake posts:rebake still crunching t…

---

## [Manipulating custom user fields from the Rails console](https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613)

<div class="topic-metadata">

**Author:** [@nathank](https://meta.discourse.org/u/nathank)\
**Replies:** 7\
**Last updated:** [August 5, 2022, 3:01am UTC](https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613 "2022-08-05T03:01:26Z")

</div>

I used this code snipped to attempt to bulk replace some data in a user custom field. I derived it from the Ning importer. users=User.where("users.created\_at \<= '2019-09-13'::timestamp") users.each do |u| u.custom\_fie…

---

## [Set or update a featured topic link via the rails console](https://meta.discourse.org/t/set-or-update-a-featured-topic-link-via-the-rails-console/166923)

<div class="topic-metadata">

**Author:** [@Canapin](https://meta.discourse.org/u/Canapin)\
**Replies:** 0\
**Last updated:** [October 11, 2020, 10:22pm UTC](https://meta.discourse.org/t/set-or-update-a-featured-topic-link-via-the-rails-console/166923 "2020-10-11T22:22:54Z")

</div>

You can set or update a featured link on a topic by using the rails console. From your server, enter the rails console from your Discourse folder: ./launcher enter app rails c You can then use the @nathank’s form to g…

---

## [Can no longer assign avatar flair by setting primary group](https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185)

<div class="topic-metadata">

**Author:** [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)\
**Replies:** 3\
**Last updated:** [July 17, 2022, 3:57pm UTC](https://meta.discourse.org/t/can-no-longer-assign-avatar-flair-by-setting-primary-group/206185 "2022-07-17T15:57:46Z")

</div>

I would like to give all users in a group an avatar flair. I used to be able to set the flair in the group settings, check the “Automatically set as primary group” option, and everyone in the group would automatically g…

[Next page](https://meta.discourse.org/tag/rails-console/466.md?match_all_tags=true&page=1&tags%5B%5D=rails-console)
