1
如何在mongodb模型和活动记录模型之间创建像has_many,has_and_belongs_to_many,belongs_to这样的关联。我有一个类Item
其使用mongoid和我有另一类ItemType
从ActiveRecord
在mongodb和活动记录之间创建关联
class Item
include Mongoid::Document
embeds_many :extra_fields, class_name: "ItemType"
end
class ItemType < ActiveRecord::Base
belongs_to :item
end
由于
以下链接可能会帮助你 http://stackoverflow.com/questions/4883643/rails-3-polymorphic-association-between-one-mongomapper-model-and-one-many-activ –