class Foo include Mongoid::Document end class Bar < Foo end
Foo.all返回Bars,Bar.all返回Foos.
我想把Foo和Bar放在不同的集合中.
我试过了
class Bar < Foo store_in collection: 'bars'
但得到了
Mongoid::Errors::InvalidStorageParent: Problem: Invalid store_in call on class Bar. Summary: The :store_in macro can only be called on a base Mongoid Document
使用Mongoid 4.0.2
解决方法
您还需要将Bar设为Mongoid文档.
class Bar < Foo include Mongoid::Document store_in collection: 'bars'