Commontator 中的分页错误 Gem

Pagination error in Commontator Gem

我在 rails 申请中使用了 'Commontator' gem。我在我的讨论选项卡中做了分页。分页允许一页有 10 条评论。当我们想在下一页阅读更多评论时,有 links。 当我单击下一个 link 时,它会将我带到第 2 页,但是当我在新选项卡中打开 link 时,它会显示一个错误: undefined method 'api_path' for #<ActionDispatch::Routing::RoutesProxy:0xe45a768>

我尝试搜索解决方案,但没有找到。

分页 links 图片:

错误图片:

我在尝试了这么多编码之后得到了这个答案。 我知道每次我在新标签页中打开 link 时,它都会搜索 polymorphic_path 但找不到。 然后在threads_controller。我更改了以下代码:

if comment.thread.commontable_type == "Api"
  main_app.api_show_url(api_name:comment.thread.commontable.name)
elsif comment.thread.commontable_type == "Product"
  main_app.company_url(comment.thread.commontable.product_name)
end

此代码将首先检查线程是针对 API 还是针对产品型号。然后相应地它将调用该模型的显示方法。