# Development

**URL:** https://meta.discourse.org/c/dev/7.md?page=102

[最新版本](https://meta.discourse.org/latest.md) · [分類](https://meta.discourse.org/categories.md) · [標簽](https://meta.discourse.org/tags.md)

**Page:** 103

---

## [标题和获取最新主题 API 的问题](https://meta.discourse.org/t/issue-with-title-and-get-latest-topics-api/132135)

<div class="topic-metadata">

**Author:** [@nakul\_krishnan1](https://meta.discourse.org/u/nakul_krishnan1)\
**回覆:** 1\
**Last updated:** [2019年十月30日 01:49 UTC](https://meta.discourse.org/t/issue-with-title-and-get-latest-topics-api/132135 "2019-10-30T01:49:53Z")

</div>

您好，\\n我们正在使用 Discourse 论坛，并为应用程序定制了用户体验。我们利用公开的 API 与 Discourse 进行交互。该用户体验中没有“标题后跟……”的概念。

---

## [不使用 Docker Hub 的 Docker 镜像？](https://meta.discourse.org/t/docker-images-without-docker-hub/132053)

<div class="topic-metadata">

**Author:** [@Derp](https://meta.discourse.org/u/Derp)\
**回覆:** 5\
**Last updated:** [2019年十月28日 22:08 UTC](https://meta.discourse.org/t/docker-images-without-docker-hub/132053 "2019-10-28T22:08:16Z")

</div>

我想自己构建，并可能简化 Discourse 的 Docker 设置。我已经在该服务器上配置了 Nginx，因此这部分是冗余的。此外，出于安全考虑，最好自行构建并托管 …

---

## [分级访问论坛的难度](https://meta.discourse.org/t/difficulty-of-tiered-access-forum/132051)

<div class="topic-metadata">

**Author:** [@Derp](https://meta.discourse.org/u/Derp)\
**回覆:** 3\
**Last updated:** [2019年十月28日 22:10 UTC](https://meta.discourse.org/t/difficulty-of-tiered-access-forum/132051 "2019-10-28T22:10:36Z")

</div>

我想创建一个 Discourse 论坛，让不同用户根据数据库中某个值的不同而拥有不同的论坛访问权限。您知道是否有相关的实现方案？如果没有，您认为实现这一功能会有多困难……

---

## [适合编程零基础用户学习自定义的地方？](https://meta.discourse.org/t/place-for-total-coding-beginners-to-learn-how-to-customise/130555)

<div class="topic-metadata">

**Author:** [@charlie\_spring](https://meta.discourse.org/u/charlie_spring)\
**回覆:** 14\
**Last updated:** [2019年十月25日 11:46 UTC](https://meta.discourse.org/t/place-for-total-coding-beginners-to-learn-how-to-customise/130555 "2019-10-25T11:46:09Z")

</div>

我可以看到 Meta 上资源的丰富性，但通常建议是针对具备一定基础编码知识的人士。我们的社区（一个致力于在我们城市构建更可持续食品系统的人群网络）由……组成

---

## [欧盟法律 - CMP 和广告插件](https://meta.discourse.org/t/eu-law-cmp-and-advertising-plugin/131859)

<div class="topic-metadata">

**Author:** [@Jono\_Brain2](https://meta.discourse.org/u/Jono_Brain2)\
**回覆:** 0\
**Last updated:** [2019年十月25日 09:56 UTC](https://meta.discourse.org/t/eu-law-cmp-and-advertising-plugin/131859 "2019-10-25T09:56:12Z")

</div>

你好 在欧盟，为了符合 GDPR 要求，在用户首次同意许可之前，我们不应加载广告或跟踪数据。 我们正在考虑使用 Quantcast CMP，我想知道如何阻止广告加载，直到用户……

---

## [如何在以下 if 语句中针对特定主题/类别/标签](https://meta.discourse.org/t/how-to-target-a-specific-topic-category-tag-in-the-following-if-statement/131852)

<div class="topic-metadata">

**Author:** [@flyingdojo](https://meta.discourse.org/u/flyingdojo)\
**回覆:** 0\
**Last updated:** [2019年十月25日 08:25 UTC](https://meta.discourse.org/t/how-to-target-a-specific-topic-category-tag-in-the-following-if-statement/131852 "2019-10-25T08:25:19Z")

</div>

我能否在以下 if 语句中针对特定的主题/分类/标签： if (Discourse.User.currentProp("topic\_count") \> 0) 如果可以，我很乐意听取您的建议！

---

## [多站点将上传内容恢复为“默认”而非实际数据库名称](https://meta.discourse.org/t/multisite-restores-uploads-to-default-instead-of-actual-db-name/130778)

<div class="topic-metadata">

**Author:** [@RGJ](https://meta.discourse.org/u/RGJ)\
**回覆:** 9\
**Last updated:** [2019年十月23日 21:45 UTC](https://meta.discourse.org/t/multisite-restores-uploads-to-default-instead-of-actual-db-name/130778 "2019-10-23T21:45:17Z")

</div>

在 Discourse 最新测试版、Docker 安装、多站点环境下。 尝试将原始数据库 REDACTED 的备份恢复到当前数据库 db8015。上传内容最终出现在默认位置，无论是在文件系统中还是在数据库中。 此问题发生在...

---

## [Discourse API：获取与帖子相关的分类](https://meta.discourse.org/t/discourse-api-get-categories-related-to-posts/131498)

<div class="topic-metadata">

**Author:** [@Magnetidog](https://meta.discourse.org/u/Magnetidog)\
**回覆:** 2\
**Last updated:** [2019年十月22日 18:06 UTC](https://meta.discourse.org/t/discourse-api-get-categories-related-to-posts/131498 "2019-10-22T18:06:27Z")

</div>

你好！ 我正在开发一个独立于 Discourse 的搜索自动补全功能，用于我们网络中连接的其他网站。在该功能中，我可以在同一个自动补全结果中混合显示来自 Discourse 和来自 … 的结果。

---

## [如何在插件中在评论页面主题上使用 topic\_query.rb 中的 apply\_custom\_query](https://meta.discourse.org/t/how-to-use-apply-custom-query-from-topic-query-rb-on-review-page-topics-in-plugin/131590)

<div class="topic-metadata">

**Author:** [@Oliver\_Walker](https://meta.discourse.org/u/Oliver_Walker)\
**回覆:** 1\
**Last updated:** [2019年十月22日 15:58 UTC](https://meta.discourse.org/t/how-to-use-apply-custom-query-from-topic-query-rb-on-review-page-topics-in-plugin/131590 "2019-10-22T15:58:51Z")

</div>

你好， 我有一个插件使用了 \`TopicQuery.add\_custom\_filter\` 函数。 它按预期将我的自定义过滤器仅应用于着陆页上显示的默认主题视图。 我注意到这是因为……

---

## [React 主题组件](https://meta.discourse.org/t/react-theme-components/131565)

<div class="topic-metadata">

**Author:** [@edL](https://meta.discourse.org/u/edL)\
**回覆:** 2\
**Last updated:** [2019年十月22日 08:27 UTC](https://meta.discourse.org/t/react-theme-components/131565 "2019-10-22T08:27:30Z")

</div>

这个问题有点奇怪，但有人尝试过使用 React 创建主题组件吗？我看到过一些让 React 与 Ember 配合使用的资料，但我不确定它们是否适用于主题开发的上下文中……

---

## [为插件添加模型](https://meta.discourse.org/t/adding-models-to-a-plugin/131569)

<div class="topic-metadata">

**Author:** [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**回覆:** 0\
**Last updated:** [2019年十月21日 17:01 UTC](https://meta.discourse.org/t/adding-models-to-a-plugin/131569 "2019-10-21T17:01:14Z")

</div>

我正在与一位客户合作，他们开发了一个插件，用于添加大量模型，例如添加帖子评分。这几乎总是一个糟糕的做法，对吧？在几乎所有情况下，都应该通过其他方式来实现……

---

## [预览插件问题](https://meta.discourse.org/t/preview-plugin-questions/131534)

<div class="topic-metadata">

**Author:** [@azawawi](https://meta.discourse.org/u/azawawi)\
**回覆:** 0\
**Last updated:** [2019年十月21日 10:12 UTC](https://meta.discourse.org/t/preview-plugin-questions/131534 "2019-10-21T10:12:30Z")

</div>

我正在开发一个内部插件，用于预览帖子附件中的内容。请您协助解答以下问题： 插件为预览功能提供 JavaScript/CSS 资源的正确方式是什么？

---

## [插件在管理页面引发异常错误——无法在没有 ID 的情况下对插件进行实例化](https://meta.discourse.org/t/plugin-causes-odd-error-on-admin-pages-cant-hydrate-plugin-without-id/131298)

<div class="topic-metadata">

**Author:** [@Oliver\_Walker](https://meta.discourse.org/u/Oliver_Walker)\
**回覆:** 3\
**Last updated:** [2019年十月18日 14:00 UTC](https://meta.discourse.org/t/plugin-causes-odd-error-on-admin-pages-cant-hydrate-plugin-without-id/131298 "2019-10-18T14:00:08Z")

</div>

您好， 我在创建插件时遇到了以下错误： 错误：无法在没有 \`id\` 的情况下水合插件 at Class.\_hydrate (discourse/models/store:330) at eval (discourse/models/store:222) at Array.map ()…

---

## [条件渲染连接器](https://meta.discourse.org/t/conditional-rendering-connector/131262)

<div class="topic-metadata">

**Author:** [@Jono\_Brain2](https://meta.discourse.org/u/Jono_Brain2)\
**回覆:** 0\
**Last updated:** [2019年十月17日 14:37 UTC](https://meta.discourse.org/t/conditional-rendering-connector/131262 "2019-10-17T14:37:12Z")

</div>

你好 我已创建一个插件，并设置了一个连接器 connectors / above-main-container 这可以正常工作，我可以使用 shouldRender 根据用户是否登录进行条件渲染。然而，我需要做的是条件...

---

## [API 查找邮箱地址，还是搜索？](https://meta.discourse.org/t/api-find-email-address-or-search/131055)

<div class="topic-metadata">

**Author:** [@alank](https://meta.discourse.org/u/alank)\
**回覆:** 4\
**Last updated:** [2019年十月17日 13:06 UTC](https://meta.discourse.org/t/api-find-email-address-or-search/131055 "2019-10-17T13:06:08Z")

</div>

我读过一篇 Discourse 帖子，以为找到了它：“SITENAME.com/admin/users/list/all.json?email=some@email.com”，这正是我需要的，即通过查询 Discourse API 来验证我们的 SSO 站点是否拥有 Discourse 成员……

---

## [Create custom db table and fields from plugin](https://meta.discourse.org/t/create-custom-db-table-and-fields-from-plugin/36164)

<div class="topic-metadata">

**Author:** [@deviousmachin3](https://meta.discourse.org/u/deviousmachin3)\
**回覆:** 8\
**Last updated:** [2019年十月16日 20:37 UTC](https://meta.discourse.org/t/create-custom-db-table-and-fields-from-plugin/36164 "2019-10-16T20:37:41Z")

</div>

Hi everyone, I’m working on developing a new plugin and I need to store some values in the database but I do not want to modify the discourse base system in any fashion. I’ve read through the beginners guide on plugin de…

---

## [目录中的新列 (/users)](https://meta.discourse.org/t/new-columns-in-directory-users/77814)

<div class="topic-metadata">

**Author:** [@Anshul\_TM](https://meta.discourse.org/u/Anshul_TM)\
**回覆:** 6\
**Last updated:** [2019年十月16日 20:34 UTC](https://meta.discourse.org/t/new-columns-in-directory-users/77814 "2019-10-16T20:34:08Z")

</div>

大家好， 我想在目录项模型中添加几列（“解决方案”和“积分”）。 我可以直接修改模型和模板的代码，但如何通过插件实现这一功能呢？ 如果 n…

---

## [为帖子正文中的链接添加类以进行样式设置](https://meta.discourse.org/t/adding-classes-to-links-in-post-body-for-styling/131027)

<div class="topic-metadata">

**Author:** [@alank](https://meta.discourse.org/u/alank)\
**回覆:** 3\
**Last updated:** [2019年十月15日 15:06 UTC](https://meta.discourse.org/t/adding-classes-to-links-in-post-body-for-styling/131027 "2019-10-15T15:06:55Z")

</div>

有没有办法绕过 Discourse 对锚点的重新格式化，以便将其显示为按钮并应用特定样式？ 该帖子是使用 \`.raw\` 属性发布的（我曾尝试使用 \`.cooked\` …）

---

## [在 Ubuntu 18.04 LTS 上开发安装](https://meta.discourse.org/t/development-install-on-ubuntu-18-04-lts/130754)

<div class="topic-metadata">

**Author:** [@JimmyX](https://meta.discourse.org/u/JimmyX)\
**回覆:** 1\
**Last updated:** [2019年十月11日 07:14 UTC](https://meta.discourse.org/t/development-install-on-ubuntu-18-04-lts/130754 "2019-10-11T07:14:58Z")

</div>

我刚刚成功在 Ubuntu 18.04 LTS Server 版的 VirtualBox 实例中安装了 Discourse。以下是我为了让它在主机上方便运行所必须执行的操作。我遵循了这些说明…

---

## [用于帖子编辑器修改的插件或主题组件？](https://meta.discourse.org/t/plugin-or-theme-component-for-post-editor-modification/130446)

<div class="topic-metadata">

**Author:** [@seanblue](https://meta.discourse.org/u/seanblue)\
**回覆:** 3\
**Last updated:** [2019年十月9日 11:03 UTC](https://meta.discourse.org/t/plugin-or-theme-component-for-post-editor-modification/130446 "2019-10-09T11:03:38Z")

</div>

说实话，我不知道该把这条帖子发在哪里，所以如果这不是合适的分类，请随意移动它。 最近我一直有兴趣改善 Discourse 的用户体验，以便在帖子中添加 Ruby 标签……

---

## [数据库 "discourse\_development" 不存在](https://meta.discourse.org/t/database-discourse-development-does-not-exist/130022)

<div class="topic-metadata">

**Author:** [@ramjke](https://meta.discourse.org/u/ramjke)\
**回覆:** 3\
**Last updated:** [2019年十月8日 11:46 UTC](https://meta.discourse.org/t/database-discourse-development-does-not-exist/130022 "2019-10-08T11:46:24Z")

</div>

在最新的 git pull 更新后，我尝试使用 rake db:create 创建数据库，但收到以下错误： rake aborted! ActiveRecord::NoDatabaseError: FATAL: 数据库 "discourse\_development" 不存在 /vagrant/discourse/li…

---

## [如何防止任务重叠？使用分布式锁（DistributedMutex）？](https://meta.discourse.org/t/how-to-use-prevent-overlapping-jobs-distributedmutex/130393)

<div class="topic-metadata">

**Author:** [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)\
**回覆:** 3\
**Last updated:** [2019年十月8日 01:47 UTC](https://meta.discourse.org/t/how-to-use-prevent-overlapping-jobs-distributedmutex/130393 "2019-10-08T01:47:07Z")

</div>

插件新手在此。我正在尝试适配一个运行时间约需一小时的插件。查看 /sidekiq 时，我发现该任务每 30 分钟运行一次。因此，在第一个任务完成之前，同一个任务的另一个实例就……

---

## [从帖子到插件路由的链接导致 404 错误](https://meta.discourse.org/t/link-from-post-to-plugin-route-leads-to-404/130218)

<div class="topic-metadata">

**Author:** [@nkls](https://meta.discourse.org/u/nkls)\
**回覆:** 0\
**Last updated:** [2019年十月4日 09:44 UTC](https://meta.discourse.org/t/link-from-post-to-plugin-route-leads-to-404/130218 "2019-10-04T09:44:23Z")

</div>

我编写了一个插件，用于添加如下路由： ./plugin.rb: after\_initialize do load File.expand\_path('../app/controllers/plugin\_controller.rb', \_\_FILE\_\_) Discourse::Application.routes.append do get '/…

---

## [如何维护每个标签中显示的标签顺序？](https://meta.discourse.org/t/how-to-maintain-topic-tag-order-which-is-displayed-in-each-tag/130041)

<div class="topic-metadata">

**Author:** [@Siddhu\_Dhangar](https://meta.discourse.org/u/Siddhu_Dhangar)\
**回覆:** 0\
**Last updated:** [2019年十月2日 13:42 UTC](https://meta.discourse.org/t/how-to-maintain-topic-tag-order-which-is-displayed-in-each-tag/130041 "2019-10-02T13:42:09Z")

</div>

我正在编写一个插件，用于按特定顺序显示主题标签。为此我已经编写了 Ruby 代码，但现在卡在了一个点上。我不知道如何在每个主题页面中渲染这些标签。我使用了 \`api.decorate...\`。

---

## [How can I customise CSS for each category? (as in having different design for each category)](https://meta.discourse.org/t/how-can-i-customise-css-for-each-category-as-in-having-different-design-for-each-category/35822)

<div class="topic-metadata">

**Author:** [@Huey\_Le](https://meta.discourse.org/u/Huey_Le)\
**回覆:** 9\
**Last updated:** [2019年十月4日 17:54 UTC](https://meta.discourse.org/t/how-can-i-customise-css-for-each-category-as-in-having-different-design-for-each-category/35822 "2019-10-04T17:54:38Z")

</div>

Hi, I’m running a game forum and I’d like to be able to customise CSS for each category so that each category will look different with each other (example: Fallout 4 category can have more post-nuclear design, Halo categ…

---

## [在封装 Discourse 时覆盖层位置错误](https://meta.discourse.org/t/overlays-misplaced-when-wrapping-discourse/130115)

<div class="topic-metadata">

**Author:** [@p0fi](https://meta.discourse.org/u/p0fi)\
**回覆:** 6\
**Last updated:** [2019年十月3日 19:51 UTC](https://meta.discourse.org/t/overlays-misplaced-when-wrapping-discourse/130115 "2019-10-03T19:51:32Z")

</div>

你好 :wave: 当我尝试包裹整个 Discourse 以启用不同颜色的侧边时，会出现覆盖层（例如用户卡片）错位的问题。 用户卡片本应紧挨着打开……

---

## [使用 Discourse API 创建原生应用](https://meta.discourse.org/t/create-a-nativeapp-with-discourse-api/130076)

<div class="topic-metadata">

**Author:** [@ewald345](https://meta.discourse.org/u/ewald345)\
**回覆:** 3\
**Last updated:** [2019年十月3日 16:06 UTC](https://meta.discourse.org/t/create-a-nativeapp-with-discourse-api/130076 "2019-10-03T16:06:28Z")

</div>

您好， 是否可以使用 Discourse API 创建原生应用？ 我想将 Discourse 与一些插件嵌入到 React Native 模板中。 是否有人有 Discourse 原生应用的经验，或者是否有成熟的解决方案……

---

## [Wrapped NoMethodError: Jobs::Jobs 模块未定义方法 \`enqueue'](https://meta.discourse.org/t/wrapped-nomethoderror-undefined-method-enqueue-for-jobs-module/130082)

<div class="topic-metadata">

**Author:** [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**回覆:** 2\
**Last updated:** [2019年十月2日 21:50 UTC](https://meta.discourse.org/t/wrapped-nomethoderror-undefined-method-enqueue-for-jobs-module/130082 "2019-10-02T21:50:38Z")

</div>

(0.3毫秒) BEGIN MiniScheduler::统计更新 (0.8毫秒) UPDATE "scheduler\_stats" SET "duration\_ms" = 19, "live\_slots\_finish" = 919924, "success" = FALSE, "error" = 'Jobs::HandledExceptionWrapper: 包装的 NoMethodError: unde…

---

## [为新的 discourse\_api 端点构建测试](https://meta.discourse.org/t/building-tests-for-new-discourse-api-endpoints/118639)

<div class="topic-metadata">

**Author:** [@kimardenmiller](https://meta.discourse.org/u/kimardenmiller)\
**回覆:** 19\
**Last updated:** [2019年十月2日 21:13 UTC](https://meta.discourse.org/t/building-tests-for-new-discourse-api-endpoints/118639 "2019-10-02T21:13:35Z")

</div>

为 discourse\_api 的 PR 添加一些投票 API 端点，它们运行正常。现在我正试图了解如何在提交 PR 之前创建测试，例如： require 'spec\_helper' describe DiscourseApi::API::Polls do su…

---

## [将 Discourse 升级到 Zeitwerk](https://meta.discourse.org/t/upgrading-discourse-to-zeitwerk/128337)

<div class="topic-metadata">

**Author:** [@kris.kotlarek](https://meta.discourse.org/u/kris.kotlarek)\
**回覆:** 13\
**Last updated:** [2019年十月2日 05:19 UTC](https://meta.discourse.org/t/upgrading-discourse-to-zeitwerk/128337 "2019-10-02T05:19:55Z")

</div>

Rails 6 ships with two autoloading modes: zeitwerk and classic. In that pull request DEV: Upgrading Discourse to Rails 6 by KrisKotlarek · Pull Request #8083 · discourse/discourse · GitHub I upgraded Rails to version 6.0…

[上一頁](https://meta.discourse.org/c/dev/7.md?page=101)

[下一頁](https://meta.discourse.org/c/dev/7.md?page=103)
