# Closing a topic in console

**URL:** https://meta.discourse.org/t/closing-a-topic-in-console/107482
**Category:** Development
**Created:** [January 25, 2019, 12:32am UTC](https://meta.discourse.org/t/closing-a-topic-in-console/107482 "2019-01-25T00:32:12Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [January 25, 2019, 2:33am UTC](https://meta.discourse.org/t/closing-a-topic-in-console/107482/2 "2019-01-25T02:33:49Z")

</div>

This should be what you are looking for:

> <https://github.com/discourse/discourse_api/blob/cd7742b9cfc4da2e897004fe328b7e562eac6a46/examples/change_topic_status.rb#L23-L33>

Edit: I read your post too quickly, you were looking for a rails console option. here’s an example you should be able to build off of:

> [@Auto-close old topics from a migrated forum](https://meta.discourse.org/t/auto-close-old-topics-from-a-migrated-forum/25448/10):
>
> I would SSH into the server and then cd /var/discourse ./launcher enter app rails c Topic.where(closed: false).where("created\_at \< '2015-01-01'").find\_each do |topic| topic.update\_status("closed", true, Discourse.system\_user) end And you should have all the topics created before January 1st 2015 closed wink

---

_[View the full topic](https://meta.discourse.org/t/closing-a-topic-in-console/107482)._
