Rails 3.0.1 Mongoid (2.0.0.20)
Class message embes_many: comments Field: comments_count end
Class Comment embedded_in :commentable, :inverse_of => :comments end
I want to select the 10 most commented posts. To do this, I need the comment_count field in Post. But since my comment is polymorphic (Post.comments, Message.comments, etc.), I do not want to create callbacks in Post. What I will not do is create a callback in the comment that will update the comment_count field in Post.
I do not know how I can perform an operation in an embedded document in a field from a source document and execute this callback from a parrent document
source share