Ruby on rails 在Mongoid中实现困难的模型关系
如果没有Ruby on rails 在Mongoid中实现困难的模型关系,ruby-on-rails,ruby-on-rails-3,mongodb,mongoid,Ruby On Rails,Ruby On Rails 3,Mongodb,Mongoid,如果没有has\uuu到,则无法在mongoid中实施提供的方案: 用户有许多帖子,并且属于许多项目,并且,根据在某些项目中的参与情况,属于某些部分,可以在项目中担任管理员 该部分有许多项目、用户和帖子 这个项目有很多帖子和用户,属于很多部门,有些用户是这里的管理员(归属关系?) 文章属于一个用户、项目和多个部分 怎么做 什么都使用多态关联 我的代码:我自己完成:) # Models: class User has_and_belongs_to_many :projects has_ma
has\uuu到,则无法在mongoid中实施提供的方案:
用户有许多帖子,并且属于许多项目,并且,根据在某些项目中的参与情况,属于某些部分,可以在项目中担任管理员
该部分有许多项目、用户和帖子
这个项目有很多帖子和用户,属于很多部门,有些用户是这里的管理员(归属
关系?)
文章属于一个用户、项目和多个部分
怎么做
什么都使用多态关联
我的代码:我自己完成:)
# Models:
class User
has_and_belongs_to_many :projects
has_many :posts, inverse_of: :author
end
class Project
has_and_belongs_to_many :users
has_many :posts, inverse_of: :project
end
class Post
belongs_to :project, inverse_of: :posts
belongs_to :author, class_name: 'User'
end