# Bloquear una publicación en la consola

**URL:** <https://meta.discourse.org/t/locking-a-post-in-the-console/106410>\
**Category:** Development\
**Created:** [13 Enero, 2019 11:15 UTC](https://meta.discourse.org/t/locking-a-post-in-the-console/106410 "2019-01-13T11:15:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![fhe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhe/32/113345_2.png) [@fhe](https://meta.discourse.org/u/fhe)\
**Post date:** [13 Enero, 2019 11:28 UTC](https://meta.discourse.org/t/locking-a-post-in-the-console/106410/2 "2019-01-13T11:28:35Z")

</div>

I assume that you refer to closing a topic.

I’d either use the API for that or the corresponding method on the `Topic` type:

```plaintext
Topic.where(closed: false, category_id: <catid>, id: <tid>).find_each do |topic| 
  topic.update_status("closed", true, Discourse.system_user)
end

```

Edit: I just realize that locking posts is something different. You can set the `post.locked_by_id` but I guess you’re not creating a logged staff action in that case.

---

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