我有三个模型:
class User
include Mongoid::Document
field :name, :type => String
has_many :comments
embeds_many :posts
end
class Post
include Mongoid::Document
field :title, :type => String
field :body, :type => String
embeds_many :comments
belongs_to :user
end
class Comment
include Mongoid::Document
field :text, :type => String
belongs_to :user
embedded_in :post
end
我有这个错误:
Referencing a(n) Comment document from the User document via a relational association is not allowed since the Comment is embedded.
好的,没错。但是我该如何存储,谁写了评论?