# /categories\_and\_latest 和 /categories 页面显示错误

**URL:** <https://meta.discourse.org/t/categories-and-latest-and-categories-pages-shows-error/354600>\
**Category:** Support\
**Created:** [2025年二月26日 11:47 UTC](https://meta.discourse.org/t/categories-and-latest-and-categories-pages-shows-error/354600 "2025-02-26T11:47:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![honzao](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@honzao](https://meta.discourse.org/u/honzao)\
**Post date:** [2025年二月26日 11:47 UTC](https://meta.discourse.org/t/categories-and-latest-and-categories-pages-shows-error/354600/1 "2025-02-26T11:47:02Z")

</div>

您好，

我们的网站在打开 `/categories_and_latest` 或 `/categories` 页面时出现 500 错误。

错误详情为：

```plaintext
ArgumentError (comparison of Integer with nil failed)
app/models/category_list.rb:235:in `<='
app/models/category_list.rb:235:in `block in sort_unpinned'
app/models/category_list.rb:234:in `each'
app/models/category_list.rb:234:in `sort_unpinned'
app/models/category_list.rb:42:in `initialize'
app/controllers/categories_controller.rb:648:in `new'
app/controllers/categories_controller.rb:648:in `fetch_category_list'
app/controllers/categories_controller.rb:43:in `index'
app/controllers/application_controller.rb:427:in `block in with_resolved_locale'
app/controllers/application_controller.rb:427:in `with_resolved_locale'

```

在 3.3.3 版本（生产环境）中无法重现此问题，但在 3.3.4 或 3.4.1 版本（暂存环境）中却出现了。

不确定是数据库不一致还是 bug。

此致，  
Jan

---

<div class="post-metadata">

**Author:** ![honzao](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@honzao](https://meta.discourse.org/u/honzao)\
**Post date:** [2025年二月27日 10:37 UTC](https://meta.discourse.org/t/categories-and-latest-and-categories-pages-shows-error/354600/2 "2025-02-27T10:37:30Z")

</div>

这是问这类问题的正确类别，还是我应该去别的地方问？

谢谢，  
Jan

---

<div class="post-metadata">

**Author:** ![TRgala\_Murat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/trgala_murat/32/484588_2.png) [@TRgala\_Murat](https://meta.discourse.org/u/TRgala_Murat)\
**Post date:** [2025年二月27日 10:59 UTC](https://meta.discourse.org/t/categories-and-latest-and-categories-pages-shows-error/354600/3 "2025-02-27T10:59:08Z")

</div>

category.some\_attribute || 0 # 如果为 nil，则回退到 0。你有机会尝试一下吗？

我认为我最近遇到了类似的错误。我是这样解决的。

---

<div class="post-metadata">

**Author:** ![honzao](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@honzao](https://meta.discourse.org/u/honzao)\
**Post date:** [2025年二月28日 08:44 UTC](https://meta.discourse.org/t/categories-and-latest-and-categories-pages-shows-error/354600/4 "2025-02-28T08:44:40Z")

</div>

您好，  
非常感谢您的回复。我一定会尝试一下，但这听起来更像是一个临时的解决方案。

我想了解 c.num\_featured\_topics 何时会变成 nil，并设法解决这个问题。

Jan
