# \`NoMethodError in TopicsController#show\` error after merging topics

**URL:** <https://meta.discourse.org/t/nomethoderror-in-topicscontroller-show-error-after-merging-topics/371843>\
**Category:** Bug\
**Tags:** pr-welcome, events, fixed\
**Created:** [June 26, 2025, 3:58pm UTC](https://meta.discourse.org/t/nomethoderror-in-topicscontroller-show-error-after-merging-topics/371843 "2025-06-26T15:58:31Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [June 27, 2025, 6:18am UTC](https://meta.discourse.org/t/nomethoderror-in-topicscontroller-show-error-after-merging-topics/371843/4 "2025-06-27T06:18:49Z")

</div>

FWIW I think I can simplify the repro:

- Enable both `Calendar enabled` and `Discourse post event enabled`
- As admin, create Topic1
- As admin, create Topic2 and include a post event using ‘Create event’ from the circle-with-a-plus composer menu
- As admin, go to Topic1 and use the topic wrench to select the OP and merge into Topic2 with ‘preserve chronological order after merging` checked

At this stage the post event is now no longer the OP of the topic for Topic2

- As admin, delete Topic2 using either the post delete of the OP or the topic delete option

Result: borkity bork. Deleted topic inaccessible. Error in `/logs` of `NoMethodError (undefined method ‘category_id’ for nil)`

* * *

Would the fix here be to prevent the merge that would replace the event as the OP?

When trying to merge an event post (one correctly placed in an OP) into another topic it’s blocked with this in the logs:

`Failed to process hijacked response correctly : ActiveRecord::RecordNotSaved : An event can only be in the first post of a topic`

(The UI error is more generic, ‘There was an error moving posts.`, which would be nice if it was more verbose)

Could something similar be applied to prevent a merge moving the event out of the OP position?

---

_[View the full topic](https://meta.discourse.org/t/nomethoderror-in-topicscontroller-show-error-after-merging-topics/371843)._
