我在我的rails3应用程序中设置了mongoid,并创建了2个模型。 一个模型是用户,另一个模型是文章。我如何公开一个Mongoid嵌入式集合?
既然每个用户都可以创建很多文章,我已经把:
embedded_in :user
模型/ article.rb文件
,并:
embeds_many :articles
模型/ user.rb文件。
现在,如果我通过'app_url/articles/random_article_id'访问文章,我得到以下错误。
Access to the collection for Article is not allowed since it is an embedded document, please access a collection from the root document.
虽然我想保持关系,但我希望文章能够被任何人访问。我怎样才能做到这一点??