Unlisting a topic in the ruby console

How do you unlist a topic in the ruby console?

You do so through the rails console that comes with discourse.

Get a rails console open (in a normal install run this as root on your server)

cd /var/discourse
./launcher enter app
rails c

Execute below query where 11 is the topic ID visible in the URL bar (this topic’s ID is 107060)

Topic.where(id: "11").find_each do |topic| topic.update_status("visible", false, Discourse.system_user) end

The system user will unlist the topic.