【发布时间】:2015-02-27 07:06:11
【问题描述】:
例如,如何在 mongodb 模型和活动记录模型之间创建 has_many、has_and_belongs_to_many、belongs_to 等关联。我有一个使用 mongoid 的类 Item,我还有一个继承自 ActiveRecord 的类 ItemType
class Item
include Mongoid::Document
embeds_many :extra_fields, class_name: "ItemType"
end
class ItemType < ActiveRecord::Base
belongs_to :item
end
谢谢
【问题讨论】:
-
以下链接可能对您有所帮助stackoverflow.com/questions/4883643/…
标签: ruby-on-rails mongodb activerecord