【问题标题】:What do the numbers represent in an AssociationTypeMismatch error?AssociationTypeMismatch 错误中的数字代表什么?
【发布时间】:2015-08-19 23:47:34
【问题描述】:

我在使用 Rails 控制台尝试分配时得到以下结果。

ActiveRecord::AssociationTypeMismatch: PurchaseOrder(#70303731156560) expected, got PurchaseOrder(#70303775861760)

#70303731156560#70303775861760 代表什么?

【问题讨论】:

  • 我相信那些是class.object_id的

标签: ruby-on-rails exception rails-activerecord


【解决方案1】:

当出现ActiveRecord::AssociationTypeMismatch 错误时,类名后面的数字表示该类的不同版本。当加载了两个不同版本的模型时会发生此错误。

要解决这个问题,您可以在控制台中使用reload!。或者,重新启动控制台应该可以解决它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-13
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-11
    相关资源
    最近更新 更多