I think it's a best practice to embed replies to a specific message inside that message and I'm trying to implement it using mongoid. here is what I have
class Message
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
field :subject
field :body
field :sender_deleted, :type => Boolean, :default => false
field :recipient_deleted, :type => Boolean, :default => false
field :read_at, :type => DateTime
referenced_in :sender, :class_name => "User", :inverse_of => :sender, :foreign_key => 'sender_id'
referenced_in :recipient, :class_name => "User", :inverse_of => :recipient, :foreign_key => 'recipient_id'
embeds_many :replies, :class_name => 'Message', :stored_as => :array
embedded_in :message, :inverse_of => :replies
here is the part where I try to define the message and its replies relation:
embeds_many :replies, :class_name => 'Message', :stored_as => :array
embedded_in :message, :inverse_of => :replies
it's not working for me and I don't know why, any idea how I can do such a thing?