在我的rails应用程序中,我有两个模型:
Person和Company.我需要在这些对象的任何对之间指定多对多关系.所以我应该能够这样做:
@connections = @person.connections
Run Code Online (Sandbox Code Playgroud)
其中@connections是一个Person和Company对象的数组.
现在我已经ConnectionBinding为此创建了模型,它不能按原样运行:
class ConnectionBinding < ActiveRecord::Base
belongs_to :connect_from, polymorphic: true
belongs_to :connect_to, polymorphic: true
end
Run Code Online (Sandbox Code Playgroud)
这是个ActiveRecord::HasManyThroughAssociationPolymorphicSourceError例外
有人已经解决了这个问题吗?任何建议赞赏.