【问题标题】:How to troubleshoot private method 'through_reflection' called for ActiveRecord::Associations?如何对 ActiveRecord::Associations 调用的私有方法“through_reflection”进行故障排除?
【发布时间】:2018-01-14 21:50:15
【问题描述】:

我在 rails 5.2 中遇到过几次这个错误(在此之前没有注意到或发现它)。我无法在 SO 或 rails 文档上找到任何好的信息。我终于弄清楚它是什么了……所以,我想我会在这里发布一个 Q/A 以供其他人查找。

private method `through_reflection' called for #<ActiveRecord::Associations::HasManyThroughAssociation:0x00007ff1d4511878>

【问题讨论】:

    标签: activerecord ruby-on-rails-5


    【解决方案1】:

    这不是一个描述性很强的错误...这意味着(可能)是您在定义 through 之前调用了 has_many through。您需要重新排序您的关联。

    或者,您的 has_many through 关联格式不正确。同样,该错误对于找出究竟出了什么问题并没有多大帮助。

    【讨论】:

      猜你喜欢
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多