Can't delete this category because it has 1 topic

Continuing the discussion from Using topic.destroy(id) to delete illegal content:

Unsure of how to remove this topic, because it spits back an error.

Once this topic is removed, the category will be removed as well.

2 Likes

Move the Topic to another Category. If you want tjis topic to not be viewable. Move it to a private category like staff for example. The topic will delete itself once your time has past to fully delete topic.

Tried moving, but I see: Sorry, an error has occurred.

Summary

Message

NoMethodError (undefined method revise' for nil:NilClass) lib/topics_bulk_action.rb:101:in block in change_category’
lib/topics_bulk_action.rb:98:in change_category' lib/topics_bulk_action.rb:28:in perform!’
app/controllers/topics_controller.rb:879:in bulk' app/controllers/application_controller.rb:358:in block in with_resolved_locale’
app/controllers/application_controller.rb:358:in with_resolved_locale' lib/middleware/omniauth_bypass_middleware.rb:68:in call’
lib/content_security_policy/middleware.rb:12:in call' lib/middleware/anonymous_cache.rb:354:in call’
config/initializers/100-quiet_logger.rb:23:in call' config/initializers/100-silence_logger.rb:31:in call’
lib/middleware/enforce_hostname.rb:22:in call' lib/middleware/request_tracker.rb:176:in call’

Backtrace

lib/topics_bulk_action.rb:101:in block in change_category' activerecord (6.0.3.3) lib/active_record/relation/delegation.rb:87:in each’
activerecord (6.0.3.3) lib/active_record/relation/delegation.rb:87:in each' lib/topics_bulk_action.rb:98:in change_category’
lib/topics_bulk_action.rb:28:in perform!' app/controllers/topics_controller.rb:879:in bulk’
actionpack (6.0.3.3) lib/action_controller/metal/basic_implicit_render.rb:6:in send_action' actionpack (6.0.3.3) lib/abstract_controller/base.rb:195:in process_action’
actionpack (6.0.3.3) lib/action_controller/metal/rendering.rb:30:in process_action' actionpack (6.0.3.3) lib/abstract_controller/callbacks.rb:42:in block in process_action’

Env

HTTP HOSTS: discuss.noisebridge.info

2 Likes

Not sure. With the move of the topic if you tried the select messages and move

Try to simply edit the topic title and change category there. If the topic has been deleted you may need to undelete it to edit title.

I was able to edit the topic title. It will not move or delete. I see the topic category will change if I attempt to migrate it, then immediately revert back a split second later.

There are actually two topics in the category.

  1. https://discuss.noisebridge.info/t/post/2
    Shows no option to delete. Will not move. I was able to change the topic title.

    • This was previously split into a second topic in another category.
  2. Broken Linked-Topic in different category
    I see this post will not delete either. If you attempt to delete it, it will turn red and go nowhere.

  3. https://discuss.noisebridge.info/t/about/1992/1
    This is the description for the category. Shows as -1 replies and I cannot open it.
    :( Error while trying to load Something went wrong.

Thanks for the assistance!

1 Like

Okay, I’m seeing 3 errors in the log. They are:

1st error

Summary

Message

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation “categories” does not exist
LINE 1: SELECT categories.*, t.slug topic_slug FROM “categories” LEF…
^
)
(eval):105:in exec_params' app/models/site.rb:40:in categories’
app/models/site.rb:12:in initialize' app/models/site.rb:113:in new’
app/models/site.rb:113:in json_for' app/controllers/application_controller.rb:552:in preload_anonymous_data’
app/controllers/application_controller.rb:378:in preload_json' app/controllers/application_controller.rb:358:in block in with_resolved_locale’
app/controllers/application_controller.rb:358:in with_resolved_locale' lib/middleware/omniauth_bypass_middleware.rb:68:in call’
lib/content_security_policy/middleware.rb:12:in call' lib/middleware/anonymous_cache.rb:352:in call’
config/initializers/100-quiet_logger.rb:23:in call' config/initializers/100-silence_logger.rb:31:in call’
lib/middleware/enforce_hostname.rb:22:in call' lib/middleware/request_tracker.rb:176:in call’

Backtrace

rack-mini-profiler (2.2.0) lib/patches/db/pg.rb:69:in exec_params' rack-mini-profiler (2.2.0) lib/patches/db/pg.rb:69:in exec_params’
(eval):105:in exec_params' activerecord (6.0.3.3) lib/active_record/connection_adapters/postgresql_adapter.rb:675:in block (2 levels) in exec_no_cache’
activesupport (6.0.3.3) lib/active_support/dependencies/interlock.rb:48:in block in permit_concurrent_loads' activesupport (6.0.3.3) lib/active_support/concurrency/share_lock.rb:187:in yield_shares’
activesupport (6.0.3.3) lib/active_support/dependencies/interlock.rb:47:in permit_concurrent_loads' activerecord (6.0.3.3) lib/active_record/connection_adapters/postgresql_adapter.rb:674:in block in exec_no_cache’
activerecord (6.0.3.3) lib/active_record/connection_adapters/abstract_adapter.rb:722:in block (2 levels) in log' activesupport (6.0.3.3) lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize’

Env

HTTP HOSTS: discuss.noisebridge.info

2nd error

Summary

Message (3 copies reported)

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation “categories” does not exist
LINE 1: SELECT categories.*, t.slug topic_slug FROM “categories” LEF…
^
)
(eval):105:in exec_params' app/models/site.rb:40:in categories’
app/models/site.rb:12:in initialize' app/models/site.rb:113:in new’
app/models/site.rb:113:in json_for' app/controllers/application_controller.rb:552:in preload_anonymous_data’
app/controllers/application_controller.rb:378:in preload_json' app/controllers/application_controller.rb:358:in block in with_resolved_locale’
app/controllers/application_controller.rb:358:in with_resolved_locale' lib/middleware/omniauth_bypass_middleware.rb:68:in call’
lib/content_security_policy/middleware.rb:12:in call' lib/middleware/anonymous_cache.rb:352:in call’
config/initializers/100-quiet_logger.rb:23:in call' config/initializers/100-silence_logger.rb:31:in call’
lib/middleware/enforce_hostname.rb:22:in call' lib/middleware/request_tracker.rb:176:in call’

Backtrace

rack-mini-profiler (2.2.0) lib/patches/db/pg.rb:69:in exec_params' rack-mini-profiler (2.2.0) lib/patches/db/pg.rb:69:in exec_params’
(eval):105:in exec_params' activerecord (6.0.3.3) lib/active_record/connection_adapters/postgresql_adapter.rb:675:in block (2 levels) in exec_no_cache’
activesupport (6.0.3.3) lib/active_support/dependencies/interlock.rb:48:in block in permit_concurrent_loads' activesupport (6.0.3.3) lib/active_support/concurrency/share_lock.rb:187:in yield_shares’
activesupport (6.0.3.3) lib/active_support/dependencies/interlock.rb:47:in permit_concurrent_loads' activerecord (6.0.3.3) lib/active_record/connection_adapters/postgresql_adapter.rb:674:in block in exec_no_cache’
activerecord (6.0.3.3) lib/active_record/connection_adapters/abstract_adapter.rb:722:in block (2 levels) in log' activesupport (6.0.3.3) lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize’

Env

HTTP HOSTS: discuss.noisebridge.info

3rd error

Summary

Message

Job exception: PG::UndefinedTable: ERROR: relation “application_requests” does not exist
LINE 1: SELECT “application_requests”.“id” FROM "application_request…
^

Backtrace

/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.2.0/lib/patches/db/pg.rb:69:in exec_params' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.2.0/lib/patches/db/pg.rb:69:in exec_params’
(eval):100:in exec_params' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in block (2 levels) in exec_no_cache’
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies/interlock.rb:48:in block in permit_concurrent_loads' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/concurrency/share_lock.rb:187:in yield_shares’
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies/interlock.rb:47:in permit_concurrent_loads' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in block in exec_no_cache’
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.3/lib/active_record/connection_adapters/abstract_adapter.rb:722:in block (2 levels) in log' /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize’

1 Like

If I had to guess you’ve recently setup your Discourse?

There is always an “About Category” post created at time of Category. The other post looks like one of the initial setup system posts. If you repurposed one of the initial special categories.

May need someone will with better knowledge. @codinghorror or one of the team.

You do have a nice layout from what I saw.

1 Like

When I go to About - Noisebridge, I’m seeing two topics. My assumption is that the topic with the title “About” is the About category’s “About” topic. The original title of the topic was probably “About the About category.”

Discourse automatically creates an “About” topic for every category that you create on the site. This topic does not need to be deleted before you can delete the category. If everything on your site is working correctly, you should be able to delete the other topic that’s in the category and then delete the category.

If this isn’t working for you, it’s possibly because the About topic has gotten into a weird state - it is showing in the UI as having -1 replies, so it looks like something has gone wrong with it. Possibly you have deleted the topic’s first post from your site’s backend. If that is the case and you are now unable to delete the category, let us know and we’ll try to come up with a solution.

3 Likes

Yes, it is pre-seeded. I’m attempting to get rid of it by transferring all of the posts to our general category with site-feedback tag.

When I attempt to delete the category I see:

Can’t delete this category because it has 1 topic. Oldest topic is About.

Are these errors linked above helpful? Thanks for the feedback.

2 Likes

What do you see if you run the following from your site’s Rails console:

Category.find 3

The ID of the category with the issue is 3. What I’m wondering about is what the value of the topic_id property for that category is.

2 Likes
Category.find 3 rails output

#<Category:0x000055cde953bee0
id: 3,
name: “About”,
color: “231F20”,
topic_id: 2,
topic_count: 1,
created_at: Thu, 06 Dec 2018 07:19:46 UTC +00:00,
updated_at: Thu, 31 Dec 2020 05:33:14 UTC +00:00,
user_id: -1,
topics_year: 1,
topics_month: 0,
topics_week: 0,
slug: “about”,
description: “All about using Discuss, and adding your suggestions to improve it.”,
text_color: “Ff0000”,
read_restricted: false,
auto_close_hours: nil,
post_count: 0,
latest_post_id: 9231,
latest_topic_id: 1992,
position: 1,
parent_category_id: nil,
posts_year: 0,
posts_month: 0,
posts_week: 0,
email_in: nil,
email_in_allow_strangers: false,
topics_day: 0,
posts_day: 0,
allow_badges: true,
name_lower: “about”,
auto_close_based_on_last_post: false,
topic_template:
"## Curious about our forum? Want to learn more?\nBe sure to check our wiki for any information you cannot find here.\n\n@help will contact our helpful volunteers. :smiling_face_with_three_hearts: \n@staff will contact all mods and admins. Remember, they are volunteers. :thank_you: \n\nIf you are seeking help on a project, check our #projects category. ",
contains_messages: nil,
sort_order: “”,
sort_ascending: nil,
uploaded_logo_id: 1349,
uploaded_background_id: nil,
topic_featured_link_allowed: true,
all_topics_wiki: true,
show_subcategory_list: false,
num_featured_topics: 5,
default_view: “”,
subcategory_list_style: “rows_with_featured_topics”,
default_top_period: “all”,
mailinglist_mirror: false,
minimum_required_tags: 0,
navigate_to_first_post_after_read: false,
search_priority: 0,
allow_global_tags: false,
reviewable_by_group_id: nil,
required_tag_group_id: nil,
min_tags_from_required_group: 1,
read_only_banner: “”,
default_list_filter: “all”>

topic_id 2

1 Like