I have two models:
class Post
include MongoMapper::Document
many :comments
key :content, String
end
and
class Comment
include MongoMapper::Document
belongs_to :post
key :post_id, ObjectId
key :content, String
end
in a rails console session I can find all Posts:
Post.all # -> [#<Post _id: BSON::ObjectId('519b0b613…
and all comments associated with a Post:
post = Post.first # -> #<Post _id: BSON::ObjectId('519b0b613e477b…
post.comments # -> [#<Comment _id: BSON::ObjectId('519d14f93e…
however, the following query strangely returns an empty array
Comment.all # -> []
Why? How can I get a list of all comments independently of the posts?