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'
原文地址:https://www.jb51.cc/ruby/264569.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。