【问题标题】:Mongoid embedded_in many documentsMongoid embedded_in 很多文档
【发布时间】:2012-09-05 22:59:10
【问题描述】:

我想要一个定义 x、y、宽度、高度、名称、...的 Image_Model 这个模型应该嵌入到许多其他模型中。

例子:

User embeds_many images
Product embeds_many images

这是可能的还是我有这样的:

User embeds_many user_images
Product embeds_many product_images

最好的方法是什么?

提前多谢

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 many-to-many mongoid


    【解决方案1】:

    有可能

    User embeds_many images
    Product embeds_many images
    

    最好只使用这个,因为您在查询图像时不必记住两个关联名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      相关资源
      最近更新 更多