How can I expose a Mongoid embedded collection?
-
30-10-2019 - |
Question
I have mongoid setup in my rails3 app, and have created 2 models. One model is user, and the other model is article.
Since I each user can create many articles, I have put:
embedded_in :user
in model/article.rb file, and:
embeds_many :articles
in model/user.rb file.
Now, if I access article by 'app_url/articles/random_article_id' I get the following error.
Access to the collection for Article is not allowed since it is an embedded document, please access a collection from the root document.
While I want to maintain relationship, I want articles to be accessible to any people. How can I do that??
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow